• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

applet-servlet communication: Error writing to server

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have trouble with my applet-servet communication. I send a file from an applet to a servlet. The servlet then sends a response "Thank you" (or an error message).

Generally this works, however it does not at one of the users. The user gets this error sending the file to the servlet:

java.io.IOException: Error writing to server
at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at AppletGUI.sendToServlet(AppletGUI.java:354)

I cannot reproduce the error, so I assume this is maybe due to a firewall. Which ports does my HTTP connection require except of 80?

This is the relevant code:




Thanks for help!
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Which ports does my HTTP connection require except of 80?


None.

catch (Exception e) {}


This is almost always a bad idea, and defintely when doing any kind of I/O. How are you going to know if there are problems?
 
Lukas Benberg
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ulf,
Sorry, I did not post the catch block, because it didn't seem relevant to me concerning my question. Of course I catch Exceptions in the servlet. However, no exception is thrown in the Servlet, because the doPost function is not invoked by the *one* user who has the problem.

I am really helpless with this problem. The user uses the latest JRE, WinXP and tested IE6 and Firefox. On my computers all this works fine (and also on the ones of other users). I think I can also exlude firewall problems, since port 80 is definitely open. Strange.

If you have any ideas where the problem could be, I am grateful!

Thanks, L
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK. You could check whether the client request ever got to your server (by checking the access log of the server), if you know when exactly this happened.

The client could also try to access other parts of your server, maybe by using a test applet that tries to connect to various URLs.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
//write to servlet
ObjectOutputStream outputToHost = new
ObjectOutputStream(servletConnection.getOutputStream());
outputToHost.writeObject(tf);
outputToHost.flush();

String header = urlcon.getHeaderField(0);//this magic string works
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the same problem i met.
If you have any ideas ,please email me.
Thanks very much!
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm facing almost exactly the same problem, only in my case the response is also a Java Object containing a pdf as byte[] or an Exception Object in case of a server side Exception.

Some users have the same IOException as in your post, no matter when and how many times they try.
At the server side, I have a ProtocolException that I do not understand:

java.net.ProtocolException: EOF after reading only: '98304' of: '197686' promised bytes, out of which at least: '512' were already buffered
at weblogic.servlet.internal.PostInputStream.complain(PostInputStream.java:91)
at weblogic.servlet.internal.PostInputStream.read(PostInputStream.java:172)
at weblogic.servlet.internal.ServletInputStreamImpl.read(ServletInputStreamImpl.java:180)
at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2140)
at java.io.ObjectInputStream$BlockDataInputStream.read(ObjectInputStream.java:2539)
at java.io.ObjectInputStream$BlockDataInputStream.readFully(ObjectInputStream.java:2569)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1584)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1271)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1835)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1759)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:322)
at my.own.package.SendAction.execute(SendAction.java:123)

The number of bytes in the error message are always the same if the user tries multiple times. Has any one seen this Exception before? Can anyone explain me what it means? I guess that a TCP packet is lost and that server gives up trying to read the incomming request, but I'm not sure at all. Especially not as this happens for a minority of users every time again, and always at the same byte.

A custom Exception indicating a transfer error is stored in a JavaObject which is returned to my applet.
From the applet logging, I can see that the user has been sending for 4 minutes and 36 seconds. I have the exact same stacktrace in my applet (on the HttpURLConnection.getInputStream()). The timeout on the servers is 5 minutes;

Until now, I have never succeeded to reproduce the problem, even if I send the same data the user send.
Did any one find an explanation and/or a solution for this problem?
This is a real killer.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic