TCP handshake not happening between windows client and linux server - java

I'm really scratching my head around this one.
I'm running a java server against a few test cases through a test tool and I'm getting a java socket timed out exception. The test tool runs on windows, while my server is deployed on a Raspbian. The test tool is black box so I do not know its implementation.
From what I gathered, the test case creates a client sending an http address to my server, say http://192.168.1.100:8080, in which my server is to make a connection and send data back to it. The port number is not static.
I verified that the port is opened by the system each test. I then placed Wireshark on the test tool's machine and found that the Syn packet made it to the machine, but Syn/Ack was never sent out.
I'm using java httpURLConnection, but I've also tried to make a java socket but both resulted in the same and throwing a socket timed out.
This problem does not come up if I run the server locally with with the test tool. What make this stranger is that it also happens to another code base, which is supposed to pass the test.
I don't know why it would not connect to the port.
More information: I'm working on an Onvif device controller. Onvif essentially provides a common interface between video streaming device and client applications. The server needs to conform to Onvif specs and passes the Onvif device test tool.
The problem above happens with test cases related to base event handlings, which follows WS-BaseNotification specs.The serer is given an endpoint so it can use to notify the client. However, given that that I'm getting a socket timed out, I don't think it is a schema parsing problem. The server throw an exception before any data was written to the output stream. The same problem happens with another code base which is supposed to be pass the test tool but the test tool also report that the notification was not delivered.

Related

Simulate an Http client disconnection before the server reply

The problem:
I am having some strange behaviour from a Jetty server (rest over https) when some client connections are closed (client-side) before the server has had time to reply. Normally this is well managed and expected by a webserver/application server but in a specific instance something breaks the server that stops replying.
I am trying to reproduce programmatically and locally the issue, opening a client connection and closing it before the server has had time to reply, but I do not have much experience with a situation like this, normally the clients I write are expected to not die immediately.
I am not interested in the language/application I have to use to replicate my case, it can be a Java program, a netcat command, telnet, dotnetcore... The only limit I have is that it should run on a Kubernetes pod, if possible.
I am trying to use Java to open a socket then close it immediately, or to create an Http client and stop it immediately after a request sent, but with no luck at the moment.
At the same time I am looking at netcat, but I fear it's too low level for a rest request.

Android Socket Connects to IP address that has nothing on it

I am having some problems with Sockets on Android. I have an app to which I am adding sockets, so the first thing I did was implement the sockets in a demo application. What it does is it loops through 255 IP addresses in the range 192.168.0.0 - 192.168.0.255 when it successfully connects the server writes data to the output stream and and the client reads the data and displays it to the user, this allows me to scan the wifi network for servers and list them to the user to allow the user to connect to one of them.
As soon as I run the exact same code within the existing application it starts doing strange things. The main issue at the moment is it is successfully connecting to every IP address in the loop.
Attached is a screenshot showing the incorrect behavior I am experiencing. I am expecting an exception being thrown when it tries to connect to an IP address with nothing to connect to.
The server in the example is running on IP 192.168.0.139 on port 6111 so I am expecting that all other IP's should throw the exception.
It does work as expected in my sample project I created to test this. So the first thing I did was make sure that the code is identical and then that all the gradle file config settings are the same, so I can confirm that they are using the same build tools and targetSdk version.
What else can I check to figure out why in the demo project it works but in the actual app it does not?

how to debug RMI/IIOP through internet?

I have a client/server applciation that communicates through JNDI/RMI/IIOP using, on client side, some Glassfish client code (NOT packaged as a Glassfish client) and on server side a Glassfish instance.
I have some Glassfish multimode scripts that I use to make sure the domains I create on any machines are totally identical and correctly configured.
Using that script on local network, I have already made sure I could access a remote Glassfish server instance from client code on my machine (that was quite a reasonable guess, however I tend to test all things I'm not totally sure of).
Next step is to have that client/server application working over (I should instead say "through") internet : with my client code in my company LAN (in other words on my machine) and my server code on an Amazon VM running my Glassfish server. For some reasons, the remote Glassfish is running on a Windows VM.
Obviously (as I ask that question, you can safely guess the through internet test is NOT working. And you're right.
So, to have more guesses, I started SmartSniffer both on my machine and on server.
On my machine, I can only see one TCP packet going to that server instance (and nothing coming back).
On server instance, I can see one packet entering (the client query) and one packet exiting (the server answer). That server answer looks like this :
[4/4/2012 11:47:13 AM:917]
GIOP.......(................NameService....._is_a...................NEO................ª.......(IDL:omg.org/SendingContext/CodeBase:1.0............n........172.27.63.145.Ô2....¯«Ë........e...........................
...................
... ...........&...............(IDL:omg.org/CosNaming/NamingContext:1.0.
That 172.27.63.145 address is my IP in local network.
[4/4/2012 11:47:13 AM:917]
GIOP.......2............NEO................0.......(IDL:omg.org/SendingContext/CodeBase:1.0............ô........46.137.114.###.'5....¯«Ë........d...........................
...................
... ...........&...........!...|...............$...
...f............10.241.42.###.'6.#........g..............g........default...................g...............+IDL:omg.org/CosNaming/NamingContextExt:1.0.............¢........10.241.42.208.'5...M¯«Ë....
...d... S1AS-ORB............RootPOA....
TNameService............................... ...................
... ...........&......
That 46.137.114.### is external one of my Amazon VM, and 10.241.42.### is its internal IP in amazon magical virtual server.
So it seems server is answering, no ?
But that answer never finds its way to my machine in my network.
So ... how can I check where it get lost ? Seems likepacket sniffer has done its job, but what can I do now ?
NOTE This question is a clarification of "How to Connect a glassfish client to glassfish server over NATs?"
Perhaps stupid question, but is your Amazon EC2 instance is configured with all required ports open for your communication protocol to work? You could see configured open ports in security group your instance assigned to in AWS console, under EC2->Security Groups.

Apache xml-rpc client and server implementation

I have been trying to figure out how to implement a simple xml rpc server and client with apache xml-rpc (http://ws.apache.org/xmlrpc/) but i haven't been successfull. I implemented a server and a client as specified here in the section Webserver: http://ws.apache.org/xmlrpc/server.html
The only thing i did differently was this "phm.addHandler("Calculator",org.apache.xmlrpc.demo.Calculator.class);" instead of this "phm.load(Thread.currentThread().getContextClassLoader(), "MyHandlers.properties");". When i start the server it start properly but I can't see the service when running netstat. Then when I run a request from the client it fails because it cannot find the class to call (i.e. the client doesn't really connect to the server). I have also observed that the client can start (not sending any requests) without any errors even when the server is not running.
Anyone have any ideas. I'm really lost.
Are you trying to run both client and server on the same computer? ...that may be the reason for netstat not working. (It cannot sniff packets on the loopback address.)
If you're still interested I can post a working example.

Best way to program a server status feature

Some background information.
- Running a java server on localhost
- Running a webserver on localhost
I would like a webpage to have a 'server status' feature which lets me know whether the server is running or not. My question, what is the best way to do this?
When I launch the java server, I write a flag in the database to signify that it is running.
Javascript/PHP sockets to try and bind on the same port. (Not sure if possible yet)
Shell script to locate the program in the task list.
Thanks!
When I launch the java server, I write
a flag in the database to signify that
it is running.
would not be of much help if the server should segfault.
Maybe have a look at http://mmonit.com/monit/
what is pretty much what you are looking for
I suspect the simplest method is simply for your web service (backend) to try and connect to the port that your server is running on, and provide an automatically refreshing page that reports this status. If your server goes down then you'll get an faster notification than if you're polling (say) the process table.
Of course the fact that you can connect to the port doesn't really give you an indication of whether it's working other than it's opened a port (e.g. it may have no resources etc. to service requests) but it's a start.

Categories