i encountered a problem using the apache commons-net telnet api, and hope you can help me with it.
i am connecting to a remote unix server via telnet and running a script , that at some point run an .sh file. that file open a server that needs to continue running even after the telnet connection to the client is closed. the problem is that when i close the client connection the process stops. i think that when the connection is lost there is no reference to the running process and the os is killing it but im not sure.
if that is the case i understand that if a could open the server process as a deamon process the problem will be resolve.
maybe there are other ways to do it...
can someone help me to solve this thing?
thank
moshe ben noun
A combination of nohup and running the process in the background using & should do what you are looking for.
http://www.livefirelabs.com/unix_tip_trick_shell_script/june_2003/06022003.htm
Related
I developed a java code to connect to a device and issue few POST commands. This runs well in eclipse. But when I build and run on command-line it always times out.
I am running eclipse in the same machine as command line .I am using java 8.
Network problems are best tackled by first keeping Java out of it. So as a first step, you can open up the console and try to do a telnet connection to the socket address you used in your program by entering
telnet targetserver.example.com 12345
If that times out as well, the source of your problem is not within Java.
You haven't provided much (e.g. source as requested) but my guess into the blue is that you're sitting behind a proxy that is configured in Eclipse. Eclipse passes that information to the started application so the connection works. Starting the application on the console lacks this information, so the network connection is attempted directly without going via the proxy.
I have compiled and executed some proof-of-concept code using the java-ews-api, and have had success when running it under windows. THe same code times out when I run it under linux. Firewalls seem as if they are the most likely suspect, but I can ping the exchange server from eh Linux server.
Could you offer suggestions as to what I should test or research?
Thanks in advance
Thinking about the situation some, it became clear to me that it's simply a firewall issue. The simplest way for me to test connectivity to my Exchange server (using https) was via netcat:
netcat webmail.mydomain.com 443 < /dev/null; echo $?
That will print zero (0) if port 443 is open on that host, and a one (1) if it is closed.
I am doing load test for my project, when i tried to use jconsole to monitor when the server is restarted connection is getting lost is there any solution for this?
Thanks
jconsole connects to a process, when the server is restarted it gets a new process id, and jconsole did not know of the new process that is created. There is no other but you have to connect it yourself.
Jconsole is connected to a process (jvm). When your server is stop, the process doesn't exist anymore and so the jconsole connection is lost. And so you have to connect jconsole to the new process created when you server is starting.
is there any solution for this?
One way to ease the pain is to use a JMX URL instead of a process ID. The JMX URL never changes on restart so while you have to reconnect anyway, at least the process is less painful.
URLs are of the format service:jmx:rmi:///jndi/rmi://hostName:portNum/jmxrmi. Not sure what your server is, but here's how to enable it on tomcat.
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.
when i try to start my java based server there is a message that says the port is already in use...
And all my java web servers are stopped... So if anyone can help me i will appreciate it...
If there is really still a process that has the port open, you can easily check for that (and close the process) via TCPView. It might be that the port is just lingering (for example due to not being shutdown properly), in which case you'd have to wait for the socket to close and check that the code is clear with regard to that.
I was trying to establish socket communication between PC(JAVA Server)<-->Android(Client)
on Debugging, popped the problem : Address already in use
instant/feasible resolution i found out was to:
run cmd as adminstrator
netstat -abn
find the process listening to the port of intrest
terminate the process from task manager
PS : Unlike from an external application mentioned in previous answers, steps in this answer allows you to find out the used ports with the resources already present.
A few options... us TCPView to find the program that has the port open and kill it... reboot... just reset the network connection. Try those.