G
Guest
I have since some time a bunch of cooperating servlets and applets. They
have been happily used generally by myself or by colleagues here in the
institute (on the same LAN), more rarely by colleagues in another
institute in the same city. Now I am trying to use them with a colleague
in another country (Belgium vs Italy) and I am having trouble.
I do not understand whether it is a bug in my code, a problem of "noise"
on the line, or an incompatibility between the Windows client in Belgium
with our Linux system (so far only Linux clients have used it).
------------------------------------------------------------------------
The arrangement and the protocol
- the user is presented with a HTML frameset with two frames. The left
frame contains a little form which has the servlet (running on my
machine) as action. The right hand frame has initially a button
used to load a page with the applet (but this is done later).
The user presses the Connect button in the left frame and this calls
the servlet.
- the servlet init method does a
if (serverSocket == null) serverSocket = new ServerSocket(14444);
(I have three servlets, one uses port 4444, one 14444 and one 54444,
I just picked up random unprivileged ports. The one I'm now testing
is the one with 14444
The servlet doPost or doGet methods (equivalent) ultimately process
the Connect request doing ...
clientSocket = (Socket) session.getValue("clientsocket") ;
if (clientSocket == null || clientSocket.isClosed()) {
clientSocket = serverSocket.accept();
...
}
i.e. a message is issued, then the servlet listens on port 14444
until a connection request is received, and opens a clientSocket.
(there is a separate one per session, kept in a session Vector)
this occurs when the user loads the HTML page with the applet
at the same time the servlet opens a JDBC connection to
a mysql server on another machine (local database server in our
institute)
- the start method of the applet attaches the client socket and
opens two streams on it
if( mySocket == null) mySocket = new
Socket("mymachine.mydomain.inaf.it", 14444);
if (appletout == null) appletout = new
PrintWriter(mySocket.getOutputStream(), true);
if (appletin == null) appletin = new BufferedReader(new
InputStreamReader(mySocket.getInputStream()));
- the user then inputs a number in the left hand side form and presses
a Go button. As result the servlet does a database search for item
"number", does other chores, then displays on the user screen a
"locked waiting for applet requests" and enters a loop reading from
the applet output stream (which is input for the servlet)
- the user can press one of three buttons in the applet (get image,
get regions, close communication).
correspondlingy the applet printlns on its output stream a
command (GOIMA, GOREG or END)
- if the servlet receives a GOIMA, sends to the applet IMGREADY
- when the applet receives IMGREADY sends back to the servlet
a SENDURL
- when the servlet receives SENDURL sends back a number N followed
by n lines each one containing an URL
- the applet reads and stores the N URLs (and uses one of them to
retrieve via http an image which it displays ... from another
"image" server)
- if the servlet receives a GOREG, sends to the applet REGREADY
- when the applet receives REGREADY sends back to the servlet
a SENDREG
- when the servlet receives SENDREG sends back a number M followed
by m lines each one containing some text
- the applet reads, parses and stores the m lines in a JTable
and does something else with them too
- if the servlet receives an END, it exits from the communication loop
and writes an "unlocked" message to the user screen
- if the user presses the Disconnect button in the left frame, the
servlet closes the clientSocket streams, cleans up the session
vectors, and closes the mysql connection
------------------------------------------------------------------------
The tests
- all this has always been working locally since ages
- when I had one external user (elsewhere in town) I had to tune
somehow the delays. Also he originally had a firewall blocking
port 14444 so he had to open it
- when now I had troubles with a user in Belgium, I thought it
was another firewall problem. So I asked her to do a test I
already used in the past :
- one has to start the servlet "instance" using the left hand
side form, but WITHOUT starting the applet ...
... instead of this she telnets to my machine on port 14444
and issues the GOIMA SENDURL GOREG SENDREG END commands to
exercise the handshake (giving normal servlet commands from
the form)
- while this is done, I keep a watch (lsof -i loop) on the sockets
for the servlet user and pid
apparently the "typical course of events" I see is (if I exercise
this locally)
- Connect button
I see port 14444 in LISTEN
I see an arbitrary port attached to the db host mysql port
I see my port http-alt (?) attached to an arbitrary high port
- telnet 14444 or start applet
The db mysql port remains
The rest is replaced by my 14444 attached to an arbitrary high port
Now, apart why exactly http-alt, this is clear and clean
------------------------------------------------------------------------
The problem
My user in Belgium can run the telnet test with no problems (i.e. the
servlet replies correctly, there are no packets lost, the handshake is
fine).
However when she starts the applet and then tries to exercise the
handshake under real conditions I see funny things on my ports.
I initially see a connection from my http-alt to some arbitrary
port on her system (which my lsof decodes with funny names like
cogitate, tomato-springs, or other names each time different).
Also typically one sees the port attached to http-alt shift from
one name to another but not go away, while 14444 attaches to
another arbitrary port with a funny name
... after this I guess the system gets confused as there are
two sockets between applet and servlet and the commands are
routed in some random way
My correspondent is using Firefox/3.0.5 under Windows XP 2002 SP2,
if that matters anyhow.
Any obvious suggestion that this behaviour might be due to a
Windows/Linux incompatibility ? Or to a bug in my code (but it did work
with other Linux users) ?
If anybody wishing to have a test run, we could negotiate access to the
real thing (although it accesses proprietary astronomical data, I guess
it could be arranged).
have been happily used generally by myself or by colleagues here in the
institute (on the same LAN), more rarely by colleagues in another
institute in the same city. Now I am trying to use them with a colleague
in another country (Belgium vs Italy) and I am having trouble.
I do not understand whether it is a bug in my code, a problem of "noise"
on the line, or an incompatibility between the Windows client in Belgium
with our Linux system (so far only Linux clients have used it).
------------------------------------------------------------------------
The arrangement and the protocol
- the user is presented with a HTML frameset with two frames. The left
frame contains a little form which has the servlet (running on my
machine) as action. The right hand frame has initially a button
used to load a page with the applet (but this is done later).
The user presses the Connect button in the left frame and this calls
the servlet.
- the servlet init method does a
if (serverSocket == null) serverSocket = new ServerSocket(14444);
(I have three servlets, one uses port 4444, one 14444 and one 54444,
I just picked up random unprivileged ports. The one I'm now testing
is the one with 14444
The servlet doPost or doGet methods (equivalent) ultimately process
the Connect request doing ...
clientSocket = (Socket) session.getValue("clientsocket") ;
if (clientSocket == null || clientSocket.isClosed()) {
clientSocket = serverSocket.accept();
...
}
i.e. a message is issued, then the servlet listens on port 14444
until a connection request is received, and opens a clientSocket.
(there is a separate one per session, kept in a session Vector)
this occurs when the user loads the HTML page with the applet
at the same time the servlet opens a JDBC connection to
a mysql server on another machine (local database server in our
institute)
- the start method of the applet attaches the client socket and
opens two streams on it
if( mySocket == null) mySocket = new
Socket("mymachine.mydomain.inaf.it", 14444);
if (appletout == null) appletout = new
PrintWriter(mySocket.getOutputStream(), true);
if (appletin == null) appletin = new BufferedReader(new
InputStreamReader(mySocket.getInputStream()));
- the user then inputs a number in the left hand side form and presses
a Go button. As result the servlet does a database search for item
"number", does other chores, then displays on the user screen a
"locked waiting for applet requests" and enters a loop reading from
the applet output stream (which is input for the servlet)
- the user can press one of three buttons in the applet (get image,
get regions, close communication).
correspondlingy the applet printlns on its output stream a
command (GOIMA, GOREG or END)
- if the servlet receives a GOIMA, sends to the applet IMGREADY
- when the applet receives IMGREADY sends back to the servlet
a SENDURL
- when the servlet receives SENDURL sends back a number N followed
by n lines each one containing an URL
- the applet reads and stores the N URLs (and uses one of them to
retrieve via http an image which it displays ... from another
"image" server)
- if the servlet receives a GOREG, sends to the applet REGREADY
- when the applet receives REGREADY sends back to the servlet
a SENDREG
- when the servlet receives SENDREG sends back a number M followed
by m lines each one containing some text
- the applet reads, parses and stores the m lines in a JTable
and does something else with them too
- if the servlet receives an END, it exits from the communication loop
and writes an "unlocked" message to the user screen
- if the user presses the Disconnect button in the left frame, the
servlet closes the clientSocket streams, cleans up the session
vectors, and closes the mysql connection
------------------------------------------------------------------------
The tests
- all this has always been working locally since ages
- when I had one external user (elsewhere in town) I had to tune
somehow the delays. Also he originally had a firewall blocking
port 14444 so he had to open it
- when now I had troubles with a user in Belgium, I thought it
was another firewall problem. So I asked her to do a test I
already used in the past :
- one has to start the servlet "instance" using the left hand
side form, but WITHOUT starting the applet ...
... instead of this she telnets to my machine on port 14444
and issues the GOIMA SENDURL GOREG SENDREG END commands to
exercise the handshake (giving normal servlet commands from
the form)
- while this is done, I keep a watch (lsof -i loop) on the sockets
for the servlet user and pid
apparently the "typical course of events" I see is (if I exercise
this locally)
- Connect button
I see port 14444 in LISTEN
I see an arbitrary port attached to the db host mysql port
I see my port http-alt (?) attached to an arbitrary high port
- telnet 14444 or start applet
The db mysql port remains
The rest is replaced by my 14444 attached to an arbitrary high port
Now, apart why exactly http-alt, this is clear and clean
------------------------------------------------------------------------
The problem
My user in Belgium can run the telnet test with no problems (i.e. the
servlet replies correctly, there are no packets lost, the handshake is
fine).
However when she starts the applet and then tries to exercise the
handshake under real conditions I see funny things on my ports.
I initially see a connection from my http-alt to some arbitrary
port on her system (which my lsof decodes with funny names like
cogitate, tomato-springs, or other names each time different).
Also typically one sees the port attached to http-alt shift from
one name to another but not go away, while 14444 attaches to
another arbitrary port with a funny name
... after this I guess the system gets confused as there are
two sockets between applet and servlet and the commands are
routed in some random way
My correspondent is using Firefox/3.0.5 under Windows XP 2002 SP2,
if that matters anyhow.
Any obvious suggestion that this behaviour might be due to a
Windows/Linux incompatibility ? Or to a bug in my code (but it did work
with other Linux users) ?
If anybody wishing to have a test run, we could negotiate access to the
real thing (although it accesses proprietary astronomical data, I guess
it could be arranged).