Last packet not arriving after binary data transfer

Hi folks,
I have written a server app that receives a text header and a binary data block (e.g. an image). To read the text header I use a scanner "in" (to be more comfortable). Then after that I use the "bis" to get the binary data.
That works so far. I get a header and binary block and then I want to send back a header and a binary data block to the client in the same way.
My problem: In most of the cases (not always but mostly reproducable) delivering the result the last packet is not delivered to the client.
These are my streams, readers and writers:
bis = new BufferedInputStream(client.getInputStream());
sr = new InputStreamReader(bis);
in = new Scanner(sr);
bus = new BufferedOutputStream(client.getOutputStream());
response = new PrintWriter(bus);Here is the part of the file transfer back to the client:
int copyBytes = 0;
long copyTotal = 0;
byte[] copyBuf = new byte[client.getSendBufferSize()];
while ((copyBytes = cis.read(copyBuf)) != -1)
    bus.write(copyBuf, 0, copyBytes);
    copyTotal = copyTotal + copyBytes;
    System.out.println(copyBytes + "/" + copyTotal + " / " + fileSize);
    if (copyTotal >= fileSize)
        break;
bus.flush();
System.out.println("Finished copyStream");
[...]On the client I have basically the same (the other way round - first send a header + binary block and then receive it):
while ((bytesRead = bis.read(buffer)) != -1)
    fileStream.write(buffer, 0, bytesRead);
    bytesTotal = bytesTotal + bytesRead;
    System.out.println(bytesRead + "/" + bytesTotal + " / " + resultLength);
    if (bytesTotal >= resultLength)
        break;
System.out.println("here i am");The output on the server is something like:
Start copyStream
46966/46966 / 46966
Finished copyStreamOn the client it is like
38950/38950 / 46966It never comes to the point where it should say "here i am" although on the server it writes that everything has been transferred.
I found out that when I do a bus.close() at the server afterwards at the server then the last package arrives. But then I cannot continue using this connection, but I want to keep the connection waiting for additional header + binary block (or waiting for a "quit").
I tested this on Windows and Linux (for the case there could be an OS specific strange behavior).
What am I doing wrong? Wherever I search I don't find really different approaches to receive and send data. The only difference I can see from other samples is that I do use a reader and just when expecting binary data I use the underlying byte oriented stream. After flushing I go back reading from the "higher level" reader.
The strange thing is that receiving the text header and binary block on the server works fine but when sending response back to the client it does not work.
What I already tried:
I tried nulling my readers while reading from the underlying byte oriented stream for the case they get confused with the binary data and if data is read from the underlying byte oriented stream (did that on server and client side). That did not help.
I tried - as already mentioned - closing the bus stream - which closed my connection which I don't want but delivered the last package.
I also tried using different type of binary stream. I used a TIF image, JPG image and finally tried also with a text content (treated as binary data) and only with the last text content the problem did not occur. But this should not make a difference when reading the byte stream.
I am struggling now for two days with this problem and my last idea is trying to remove the readers in general and using just the binary oriented streams (which is more work for identifying the header lines which are plain text - anyway). But I have the doubt that this will not help because I already tried dropping them when transferring the binary block.
Another link that I found is [http://rox-xmlrpc.sourceforge.net/niotut/index.html|http://rox-xmlrpc.sourceforge.net/niotut/index.html] - is it possible that I have to use nio for this? - But why can I then see plenty of examples without the use of nio what sense would it then make having the "normal" sockets without nio?

jtahlborn wrote:
yes, you generally cannot mix Readers and InputStreams. you mentioned that you were reading "byte by byte". but you weren't. you were reading "char by char" (with some more buffering). as mentioned by a previous poster, put a DataInputStream on top of your BufferedInputStream and use that exclusively.Thanks, that was the reason - now it works! Thanks a very lot!
I have seen many samples and documentation where streams where taken to an upper level with readers with and without buffering. But I was not aware that I then have to use always exclusively the object on the upmost level. Reviewing some samples I can see that there is indeed no mixed usage.

Similar Messages

  • Data Package 000001 : sent, not arrived. No data load in BW 7

    Hi gurus...i am working with BW 7 and i have already had the complete data flow from SRM to BW, some Business Content extractors and somo others generic extractors. We have created transformations, info packages and DTP's, in fact we have loaded master data and transactional data but since last monday data load is not working any more, now every time we manually run the infopackage the next waring message appears:
    Data Package 000001 : sent, not arrived
    and the data load just wait for an answer of SRM (with is the source system) or SRM waits a request from BW.
    We have reactivated the extractors in the SBIW, replicated and reactivated in BW (also we reactivate the transformations) and the data load is not working. Then we also regenerate the Data source but it does not work.
    Do you have and idea of what is happening or which could be the problem.
    Thanks

    Check in transaction SMQA in the source system. The communication might not be working. If there are any entries in RED, then select execute LUWs from the menu to manually process them.
    Read the error and try to resolve it before though.

  • HT1541 the email informing the giftee that album has been sent has not arrived after many resends. Email address is fine. Have even tried a second email address and still no joy!!!

    the email informing the giftee that album has been sent has not arrived after many resends. Email address is fine. Have even tried a second email address and still no joy!!!
    Anyone out there with any ideas?

    Your dad should go here:
    http://www.apple.com/support/itunes/contact/
    and follow the instructions to report the issue to the iTunes Store.
    Regards.

  • Info IDoc  : sent, not arrived ; Error passing data to port

    Hi Folks,
      While I am loading the data from R/3 I am facing the following error in Production..
    Info IDoc 2 : sent, not arrived ; Error passing data to port
    when I checked in SM59 every thing seems fine like RFC test connection and authorization check
    In BW is check the Source system saying it is Ok.
    Only the thing I found here is in TRFC, it is error when opening RFC Connection.
    but it is different in SM59 saying every thing is ok, as said above..
    Please help me in this regard
    thanks masters
    DJ

    Srinivas,
      Thanks for your prompt reply..
    user : ALEREMOTE  and password are fine..
    As told I check st22 and sm21 in both sytems, no sort dumps I found..
    Please help me its an urgent..
    thanks
    DJ
    Message was edited by:
            Jangareddy dasari

  • IPhone case has still not arrived after months of waiting

    My free iPhone case has still not arrived after months of waiting. Has anyone gotten their free case yet?

    I have the same problem, so have many others.
    http://discussions.apple.com/thread.jspa?threadID=2635350&tstart=0
    There was no record of my order. I spent over an hour on two calls to Apple, and they refused to send me the Griffin Motif that I originally ordered. The rep. I spoke to said to be patient, it just might show up, but at this point I doubt it.

  • TS2518 license number has to be reentered every time I open Aperture after having data transfer done by Apple store to a new macbook pro. How do I get the license number saved?

    I have to re-enter my Aperture license number and upgrade number every time I open Aperture after buying a new MacBook Pro and paying for the data transfer to be done at the Apple store. I can understand having to do this the first time but not every time. How can I get the license number saved?

    Aperture 3.4.3 update specifically claims to fix the serial number problem. See the Release notes.
    If you've already done the update and still have the problem, read this forum post about the same topic and a solution.

  • Help me find ghost files after botched data transfer

    I just bought a new MacBook. While setting up the OS upon first boot, I hooked up my old machine (which had a dead LCD, hence the new machine) for the data transfer. Well, after a solid hour+ of data transfer over firewire, there was an error, after which the old machine didn't seem to be a valid source of data transfer for the OS.
    So I boot up the new machine and none of my files appear to have transferred. Ok, I can transfer important things by hand, so it's no problem. I boot the old machine holding down T and it appears as a mounted volume, from which I copy my files.
    Here's the issue: that first, failed attempt to transfer files left "ghost" files somewhere eating up my HD space. Ie, if I sum up the size of all my files and folders in the / directory, they add up to around 60 Gb, which seems reasonable given all my music and such. But if I look at my main partition volume in Disk Utility, it claims I'm using a full on 179 Gb, which is totally unreasonable.
    So there's around 120 Gb of "ghost" usage laying around. How do I track it down?

    Log out and then into the newly created user account. To transfer them, choose Go to Folder from the FInder's Go menu, provide /Users/Shared/ as the path, and drag them there.
    (67061)

  • User not disabled after end date (9i)

    Hi All,
    The Disable after end date schedule task disabled 7 users but did not disable 1 user.
    Any know issue around this.
    Thanks
    Don

    Hi Gyanprakash,
    i can not try disable manually, its in production. The log for disable user is commented in log.properties. Can not change that .
    Just need to analyze, why this user was left out.
    Regards
    Don

  • Infostructure S502 not updated after certain date

    There is an infostructure S502. It is not updated after a certain date.
    It should be updated after saving in C011N.
    This problem seems to have propped up after upgrade to ECC 6.0. Before that it was working fine.

    I have tried a lot but still S502 is not properly updated. Basically the field for date i.e SPTAG is empty. Due to this when we try to select from MCRQ based on dates, no data is selected.
    Is it because of some setting in MC23?

  • Websocket binary data transfer

    i have been using websockets recently.
    In safari the websocket version is draft-hixie-thewebsocketprotocol-76
    i am implementing the websocket server using safari 5.1.3 as websocket client.
    After the websocket connection successfully done from safari iam sending the message start
    the packet in hexadecimal will be : 
                  00  73  74  61  72  74  FF
    From server i replied with the same echo packet (in text mode)then the (onmessage receive event) in safari was triggered.
    But if i reply with binary mode as stated in the document of  draft-hixie-thewebsocketprotocol-76.
                  i.e   80  05  73  74  61  72  74         
        here  80 = for binary mode
                05 = length of the data
                next five bytes data    
    after sending this packet the (onmessage receive event) in safari did not triggered

    Hi,
    don't have any immediate advice, how to solve your problem in first place. You will have to do some debugging. Here is a link to start with
    http://help.sap.com/saphelp_nw04/helpdata/en/70/717cfb7d226e44ad4960877da612a4/frameset.htm
    Regards
    Gregor
    Ps. We are at the same dilemma, quite comfortable with tomcat and fighting the new beast NW, haha, still some way to go to reach expert status

  • TABLESPACE cleanup not happening after table data delete

    Hi all
    I have a partitioned table with 4 partitions all residing in a single tablespace. I populated the table with sample data and then deleted all with a simple delete statement followed by a commit. But the tablespace is still showing data from the 4 partitions under the bytes column in query below:
    select segment_name, partition_name, tablespace_name, bytes
    from dba_segments
    where tablespace_name='tb_name'
    Am I missing something here? Do I need to run some other command after delete and commit to fully flush out the data?
    FYI, my system specs are:
    Windows 2008 Server Standard (32-bit)
    ORACLE 11.1.0.7.0

    HI,
    LMT is Locally Managed Tablespace.
    +Moreover, when you say the blocks will not be available immediately when do you reckon they will be available? How do I go about automating this to free up space as soon as data is deleted?+
    You cannot automate this job, this is already automated by Oracle.
    +FYI, both pct_free and pct_used come up as empty values for my table.+
    reason for a NULL-value for PCT_USED is that the tablespace where the table resides uses automatic segments space management (ASSM). With ASSM there is no need for PCT_USED only for PCT_FREE. Oracle manages blocks automatically.
    You dont worry about releasing the space, Oracle will take care of it automatically.
    Go through the below link
    [http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/tspaces.htm#ADMIN10065]
    [http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/schema.htm#sthref2100]
    [http://www.dba-oracle.com/art_builder_assm.htm]
    This is an extract form Oracle docs
    Understanding Reclaimable Unused Space
    Over time, updates and deletes on objects within a tablespace can create pockets of empty space that individually are not large enough to be reused for new data. This type of empty space is referred to as fragmented free space.
    Objects with fragmented free space can result in much wasted space, and can impact database performance. The preferred way to defragment and reclaim this space is to perform an online segment shrink. This process consolidates fragmented free space below the high water mark and compacts the segment. After compaction, the high water mark is moved, resulting in new free space above the high water mark. That space above the high water mark is then deallocated. The segment remains available for queries and DML during most of the operation, and no extra disk space need be allocated.
    You use the Segment Advisor to identify segments that would benefit from online segment shrink. Only segments in locally managed tablespaces with automatic segment space management (ASSM) are eligible. Other restrictions on segment type exist. For more information, see "Shrinking Database Segments Online".
    If a table with reclaimable space is not eligible for online segment shrink, or if you want to make changes to logical or physical attributes of the table while reclaiming space, you can use online table redefinition as an alternative to segment shrink. Online redefinition is also referred to as reorganization. Unlike online segment shrink, it requires extra disk space to be allocated. See "Redefining Tables Online" for more information.Regards,
    Vijayaraghavan K

  • EE TV Free Tablet offer not arrived after a month

    I signed up for EE TV over a month ago and applied for my free tablet straight away - it still hasn't arrived  Any idea how I can contact someone about this?

     Why after 5 calls (we have the reference numbers) over a 90 days are we still waiting for a tablet? Your staff do seem genuinely apologetic but this problem is not being resolved.  Not the first time we have complained, nor the second, or third...you know where this is heading... right? We feel aggrieved, cheated, unvalued as a customers and cannot understand your organisations lack of timely and satisfactory resolution for this awfully frustrating situation. If within 48 hours you have not satisfactorily resolved this issue with us, we will be starting a social media campaign to try and discover just how widespread your incompetent customer service methodology and failing delivery system has reached in impacted genuine and loyal customers!     Perhaps some collective action and the raised public awareness in your organisations failings, will positively impact your endeavours to treat your customers in the manner your literature  and salespeople pledge?

  • TS4006 could not activate after erase data from icloud

    I erase all date from Icoud was lost my iphone 5, after i found it back , i would like to activate back, But could not successful, There is a massage say" your iphone could not be activate becaue the activate server is temporarily un avaliable. Try connecting your iphone to ITunes to activate it. or try a couple of minutes."
    I have try to connect ITunes on my mac and pc, also the same issue.
    Please Help!!!!

    Hello Frankieyang,
    The following article provides some additional troubleshooting steps that can help get your iPhone activated.
    iPhone: Troubleshooting activation issues
    http://support.apple.com/kb/TS3424
    Cheers,
    Allen

  • Siri is not working after transfering data from my old iphone to the new iphone

    i just bought the new 4s and i synced it with my itunes to transfer everything over and now siri wont work. she keeps saysing somethings wrong please try this again.  any ideas

    she worked right out of the box and then when i synced to itune, bam she went down.  i read some other posts and they said shut her off in the settings tab and then turn her back on.  it worked for me but from what im reading it will probably happen again. who knows if it continues to quit working i guess i will be calling apple cuz i spent way too much money on this phone for its biggest perk not to be working

  • Using custom document protocal in B2B for Binary data transfer

    Hello All,
    Below are the steps that I am performaing in my project
    1) I am enquing the message using B2b adapter to JMS queue on SOA server
    2) I have selected opaque and binary fomat while configuring the JMS adapter
    3) Before invoking b2b adapter to push the message, trying to set below proeprties in bpel
    <bpelx:toProperty name="b2b.fromTradingPartnerId"
    variable="varFromParty"/>
    <bpelx:toProperty name="b2b.toTradingPartnerId" variable="varToParty"/>
    <bpelx:toProperty name="b2b.documentTypeName"
    variable="varDocTypeName"/>
    <bpelx:toProperty name="b2b.documentProtocolVersion"
    variable="varDocTypeRevision"/>
    <bpelx:toProperty name="b2b.documentProtocolName"
    variable="varEventName"/>
    <bpelx:toProperty name="b2b.documentDefinitionName"
    variable="varDocDefName"/>
    <bpelx:toProperty name="jca.jms.JMSMessageID" variable="varMsgId"/>
    <bpelx:toProperty name="jca.jms.JMSProperty.FROM_PARTY"
    variable="varFromParty"/>
    <bpelx:toProperty name="jca.jms.JMSProperty.TO_PARTY"
    variable="varToParty"/>
    <bpelx:toProperty name="jca.jms.JMSProperty.DOCTYPE_NAME"
    variable="varDocTypeName"/>
    <bpelx:toProperty name="jca.jms.JMSProperty.DOCTYPE_REVISION"
    variable="varDocTypeRevision"/>
    <bpelx:toProperty name="jca.jms.JMSProperty.MESSAGE_TYPE"
    variable="varMsgType"/>
    <bpelx:toProperty name="jca.jms.JMSProperty.DOCPROT_NAME"
    variable="varEventName"/>
    on B2b console
    1) I have configured JMS listenign channel, file deliver channels properly
    2) I have defined docuemnt definition under custom document protocal without xsd
    custom->1.0->Binary->Binary_def
    3) created agrement and selected file as deleivery channel
    when testing this case
    - bpel- B2b adapter successfully pushing message into jms queue on soa server
    - b2b jms listening channel is able to pickup the message from jms-queue but encountering with the document protocal definition error
    - if I check reports section - sender and reciever are showing as same partner name where as in wired message all the properties(to_party, from_party etc..) are getting populated with the values that we sent from bpel
    I am not able to figure out the issue so please let us know what extra parameteres that I need to send from bpel to come out of this issue. PLease treat this as imp since i have deliverable.
    Thanks,
    Anjana

    Hi Anuj,
    Thanks for the quick response. This option fixed the issue. thanks for your suggestion.
    I tried this option earlier when I was doing some R&D, at that time message iteself was not picked up by B2b listening channel from jms queue so I have unchecked and didn't try this option again.
    Regards,
    Anjana

Maybe you are looking for

  • How to use selection-screen in function module?

    Hello I've created a function module and i have to create within the function module a selection-screen(with select-options for entering data) but i get an error that within form routines and function modules this statement is not allowed. Can anybod

  • My lock button doesn't perform his job it keeps screenshotting everytime.

    When i press my lock button, it screenshots instead  of locking my iPhone. Because of this problem I cant turn my device off when i want, mute calls or lock it. I tried resetting my iPhone, every setting goes to default but my lock button keeps makin

  • Cisco ISE & 3750 Switch MAB configuration Issue

    Hi, I am writting in response to MAB issue which I noticed a few days ago and I am still not able to undestand what exactly happend. First of all I would like to say that I configured MAB authentication and according to the MAC the ISE configure a VL

  • GTC connector,user not created...

    Hi All, I am new to OIM n just aware of the few terminologies of OIM. I created a GTC connector for flat file reconcilation then run the scheduled task.In the flat file I added two new users.After the process ,,the details of the two new users must h

  • Custom Master Page - CSS & Dynamic Display

    I have created a css file and attached it using Site Settings> Master Page> Alternate CSS URL.  This works really well and I get the customisations for the global navigation drop-downs as below including colours size etc. For my drop-downs, I'm wanti