Socket connection problems

I'm starting a server with the following code
Semaphore semaphore = new Semaphore(maxConcurrentConnections);
final ServerSocket serverSocket = new ServerSocket(Constants.NET_APPLET_PORT);
while (true) {
semaphore.acquire();
final Socket socket = serverSocket.accept();
final Runnable task = new ConnectionHandler(socket, userDatabase, messageDatabase);
final Thread thread = new Thread(task);
thread.start();
semaphore.release();
and then try to connect using
socket = new Socket(Constants.NET_HOST_NAME, Constants.NET_APPLET_PORT);
But, when I try to connect there's just a few seconds delay and the I get a ConnectionException: Connection timed out error. Any idea what could be the problem? Thanks / Joachim

If it is to any help, the same thing happens when I
try to connect from the server.Do you have a firewall?

Similar Messages

  • Sockets Connection Problem

    Hi
    I have this problem,sometimes i manage to connect to a server using sockets but sometimes it does not want to connect.cany please tell me what do you think the problem could be since sometimes it manages to connect sometimes.
    Pls

    Are u behind firewall ?
    Is it in intranet or internet ?
    when ur application fails to connect, did u check ur network connectivity via ping or sothingelse ?
    regards,
    Shahnaz.

  • Firewall & socket connection problems

    I am currently programming an instant messenger, which has a built-in server-like-structure. The application is collected in a .jar file, and launched with an executable wrapper for java archives under win32 systems.
    The thing is, it is not always possible for the chat client to perform a peer to peer connection. What the application supposed to do is, perform a POST http-request on the ip of the otherside, on 8789 port of the remote machine; when the user of the application performs a post action. However this doesn't happen in all computers we worked on, even though all the computers had the same java runtime configuration, and they were all running under Windows XP.
    I guess this situation must be existing because of the "Operating System" not letting the java application to be listening the port 8789(or any other one, 8789 is not specific at this case) and processing the requests.
    The WebServer code that exists within the client is like this:
    public final class WebServer {
    public static void main() throws Exception, SocketException {
    // Set the port number;
    int port = 8789;
    // Establish the listen socket
    ServerSocket listenSocket = new ServerSocket(port);
    // Process HTTP sevice requests in an infinite loop
    while (true) {
    // listen for a TCP connection
    Socket connectionSocket = listenSocket.accept();
    // taking the request
    BufferedReader inFromClient = new BufferedReader(new InputStreamReader(
    connectionSocket.getInputStream()));
    // Construct an object to process the HTTP request message;
    HttpRequest request = new HttpRequest(connectionSocket);
    // Create a new thread to process the request;
    Thread thread = new Thread(request);
    // Start the thread;
    thread.start();
    Does anyone have anyidea about what I should exactly do for stopping the os hassling with my built in server?

    Actually, I am listening on some port X, but there is no such "network" that I can change.
    The computers that are trying to connect each other are dial-up internet users, which do not have any connection at all. So is there any chance I could change some remote settings?
    And as far as I know, there is no other way of doing this except listening on a port (In means, there is a way, which makes a connection to a remote server's database from all users' applications, but this is far more inefficient and expensive).
    Do you think installing my application as a "Windows Service" would help the situation?

  • I suppose it is the problem with socket connection,Please help

    Hi,
    I'm trying to build a chat server in Java on Linux OS.I've created basically 2 classes in the client program.The first one shows the login window.When we enter the Login ID & password & click on the ok button,the data is sent to the server for verification.If the login is true,the second class is invoked,which displays the messenger window.This class again access the server
    for collecting the IDs of the online persons.But this statement which reads from the server causes an exception in the program.If we invoke the second class independently(ie not from 1st class) then there is no problem & the required data is read from the server.Can anyone please help me in getting this program right.I'm working on a p4 machine with JDK1.4.
    The Exceptions caused are given below
    java.net.SocketException: Connection reset by peer: Connection reset by peer
    at java.net.SocketInputStream.SocketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:119)
         at java.io.InputStreamReader$CharsetFiller.readBytes(InputStreanReader.java :339)
         at java.io.InputStreamReader$CharsetFiller.fill(InputStreamReader.java:374)
         at java.io.InputStreamReader.read(InputStreamReader.java:511)
         at java.io.BufferedReader.fill(BufferedReader.java:139)
         at java.io.BufferedReader.readLine(BufferedReader.java:299)
         at java.io.BufferedReader.readLine(BufferedReader.java:362)
         at Login.LoginData(Login.java:330)
         at Login.test(Login.java:155)
         at Login$Buttonhandler.actionPerformed(Login.java:138)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1722)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:17775)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:4141)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:253)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:261)
         at java.awt.Component.processMouseEvent(Component.java:4906)
         at java.awt.Component.processEvent(component.java:4732)
         at java.awt.Container.processEvent(Container.java:1337)
         at java.awt.component.dispatchEventImpl(Component.java:3476)
         at java.awt.Container.dispatchEventImpl(Container.java:1399)
         at java.awt.Component.dispatchEvent(Component.java:3343)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3302)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3014)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2967)
         at java.awt.Container.dispatchEventImpl(Container.java:1373)
         at java.awt.window.dispatchEventImpl(Window.java:1459)
         at java.awt.Component.dispatchEvent(Component.java:3343)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:439)
         at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:150)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:131)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
         My program looks somewhat like this :
    1st class definition:
    public class Login extends Jframe// Login is the name of the first class;
    Socket connection;
    DataOutputStream outStream;
    BufferedReader inStream;
    Frame is set up here
    public class Buttonhandler implements ActionListener
    public void actionPerformed(ActionEvent e) {
    String comm = e.getActionCommand();
    if(comm.equals("ok")) {
    check=LoginCheck(ID,paswd);
    test();
    public void test() //checks whether the login is true
    if(check)
    new Messenger(ID);// the second class is invoked
    public boolean LoginCheck(String user,String passwd)
    //Enter the Server's IP & port below
    String destination="localhost";
    int port=1234;
    try
    connection=new Socket(destination,port);
    }catch (UnknownHostException ex){
    error("Unknown host");
    catch (IOException ex){
    ex.printStackTrace ();
    error("IO error creating socket ");
    try{
    inStream = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    outStream=new DataOutputStream(connection.getOutputStream());
    }catch (IOException ex){
    error("IO error getting streams");
    ex.printStackTrace();
    System.out.println("connected to "+destination+" at port "+port+".");
    BufferedReader keyboardInput=new BufferedReader(new InputStreamReader(System.in));
    String receive=new String();
    try{
    receive=inStream.readLine();
    }catch(IOException ex){ error("Error reading from server");}
    if(receive.equals("Logintrue"))
    check=true;
    else
    check=false;
    try{
    inStream.close();
    outStream.close();
    connection.close();
    }catch (IOException ex){
    error("IO error closing socket");
    return(check);
    // second class is defined below
    public class Messenger
    Socket connect;
    DataOutputStream outStr;
    BufferedReader inStr;
    public static void main(String args[])
    { Messenger mes = new Messenger(args[0]);}
    Messenger(String strg)
    CreateWindow();
    setupEvents();
    LoginData(strg);
    fram.show();
    void setupEvents()
    fram.addWindowListener(new WindowHandler());
    login.addActionListener(new MenuItemHandler());
    quit.addActionListener(new MenuItemHandler());
    button.addActionListener(new Buttonhandle());
    public void LoginData(String name)
    //Enter the Server's IP & port below
    String dest="localhost";
    int port=1234;
    int r=0;
    String str[]=new String[40];
    try
    connect=new Socket(dest,port);
    }catch (UnknownHostException ex){
    error("Unknown host");
    catch (IOException ex){
    ex.printStackTrace ();
    error("IO error creating socket ");
    try{
    inStr = new BufferedReader(new InputStreamReader(connect.getInputStream()));
    outStr=new DataOutputStream(connect.getOutputStream());
    }catch (IOException ex){
    error("IO error getting streams");
    ex.printStackTrace();
    String codeln=new String("\n");
    try{
    outStr.flush();
    outStr.writeBytes("!@*&!@#$%^");//code for sending logged in users
    outStr.writeBytes(codeln);
    outStr.write(13);
    outStr.flush();
    String check="qkpltx";
    String receive=new String();
    try{
    while((receive=inStr.readLine())!=null) //the statement that causes the exception
    if(receive.equals(check))
    break;
    else
         str[r]=receive;
         r++;
    }catch(IOException ex){ex.printStackTrace();error("Error reading from socket");}
    catch(NullPointerException ex){ex.printStackTrace();}
    } catch (IOException ex){ex.printStackTrace();
    error("Error reading from keyboard or socket ");
    try{
    inStr.close();
    outStr.close();
    connect.close();
    }catch (IOException ex){
    error("IO error closing socket");
    for(int l=0,k=1;l<r;l=l+2,k++)
    if(!(str[l].equals(name)))
    stud[k]=" "+str[l];
    else
    k--;
    public class Buttonhandle implements ActionListener
    public void actionPerformed(ActionEvent e) {
    //chat with the selected user;
    public class MenuItemHandler implements ActionListener
    public void actionPerformed(ActionEvent e)
    String cmd=e.getActionCommand();
    if(cmd.equals("Disconnect"))
    //Disconnect from the server
    else if(cmd.equals("Change User"))
         //Disconnect from the server & call the login window
    else if(cmd.equals("View Connection Details"))
    //show connection details;
    public class WindowHandler extends WindowAdapter
    public void windowClosing(WindowEvent e){
    //Disconnect from server & then exit;
    System.exit(0);}
    I�ll be very thankful if anyone corrects the mistake for me.Please help.

    You're connecting to the server twice. After you've successfully logged in, pass the Socket to the Messenger class.
    public class Messenger {
        Socket connect;
        public static void main(String args[]) {
            Messenger mes = new Messenger(args[0]);
        Messenger(Socket s, String strg) {
            this.connect = s;
            CreateWindow();
            setupEvents();
            LoginData(strg);
            fram.show();
    }

  • Problem with socket connection

    have my gps reciver connected to the usb port - i have a daemon gpsd running which makes data available on tcp port 2947 for querying. when i do telnet, it gives proper data.
    but when i open a socket connection using java, it does not print anything as output. actually telnet asks for an escape charatcer so i am sending "r" initially to the server but still the program does not print anything as output.
    here is my java code -
    import java.io.*;
    import java.net.Socket;
    public class test2
    public static void main(String[] args)
    try
    Socket s = new Socket("localhost",2947);
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
    s.getOutputStream())),true);
    out.println("r");
    BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
    String line;
    while(true)
    line = in.readLine();
    System.out.println(line);
    catch (Exception e)
    or sometimes it even shows error as
    Exception in thread "main" java.net.SocketException: Invalid argument or cannot assign requested address
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    and this is the output which i get on telnet -
    ot@localhost ~]# telnet localhost 2947
    Trying 127.0.0.1...
    Connected to localhost.
    Escape character is '^]'.
    r
    GPSD,R=1
    $GPRMC,000212,V,18000.0000,N,00000.0000,W,0.0000,180.000,101102,,*1A
    $GPGSA,A,1,,,,,,,,,,,,,,,,*32
    $PGRME,400.00,0.00,0.00*7B
    $GPRMC,000213,V,18000.0000,N,00000.0000,W,0.0000,180.000,101102,,*1B
    $GPGSA,A,1,,,,,,,,,,,,,,,,*32
    $PGRME,400.00,0.00,0.00*7B
    $GPRMC,000214,V,18000.0000,N,00000.0000,W,0.0000,180.000,101102,,*1C
    $GPGSA,A,1,,,,,,,,,,,,,,,,*32

    Actually the problem does not seem to be in the code because i tried some basic client server programs (without any gpsd etc in picture) and even they are not working in linux though they work perfectly in windows (on the same machine). In linux it shows exception
    My socket programs dont work in linux it shows error -
    ot@localhost winc]# java parser
    Exception in thread "main" java.net.SocketException: Invalid argument or cannot assign requested address
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
    at java.net.Socket.connect(Socket.java:452)
    at java.net.Socket.connect(Socket.java:402)
    at java.net.Socket.<init>(Socket.java:309)
    at java.net.Socket.<init>(Socket.java:124)
    at parser.main(parser.java:10)
    i have removed the firewall settings etc and it still doesnot work in linux
    what could be the cause for this?
    Sowmya

  • Problem with socket connection in midp 2.0

    hello everyone.
    I'm new one in j2me and I am learning socket connection in j2me. I'm using basic socket,datagram example wich is come with sun java wireless toolkit 2.5. for it i wrote small socket server program on c# and tested it example on my pc and its working fine. also socket server from another computer via internet working fine. But when i instal this socket example into my phone on nokia n78 (Also on nokia 5800) it's not working didn't connect to socket server.. On phone I'm using wi-fi internet. Can anybody help me with this problem? I hear it's need to modify manifest file and set appreciate pressions like this
    MIDlet-Permissions: javax.microedition.io.Connector.socket,javax.microedition.io.Connector.file.write,javax.microedition.io.Connector.ssl,javax.microedition.io.Connector.file.read,javax.microedition.io.Connector.http,javax.microedition.io.Connector.https
    is it true?
    can anybody suggest me how can i solve this problem?
    where can I read full information about socket connection specifiecs in j2me?
    Thanks.

    Maybe this can be helpful:
    [http://download-llnw.oracle.com/javame/config/cldc/ref-impl/midp2.0/jsr118/index.html]
    you can check there the Datagram interface anda DatagramConnection interface and learn a little about that.
    If the client example runs fine in the wireless toolkit emulator, it should run the same way in your phone; i suggest to try to catch some exception that maybe is hapenning and display it on a Alert screen, this in the phone.

  • Problem: Socket connection is not creating in machine, through utility program (MFC Dll), on ListDisplay service port - 3334 (on separate machine), while we are able to telnet on same ListDisplay service port - 3334 from same issue machine on same time

    Problem: Socket
    connection is not creating in machine, through utility program (MFC Dll), on ListDisplay service port - 3334 (on separate machine), while we are able to telnet on same ListDisplay service port - 3334 from same issue machine on same time
    Environment: -
    OS:
    Windows XP SP2/7
    Code:
    VC 6.0
    Dll: MFC
    Problem Description: -
    We have written a utility program which create socket (Using windows standard method [MFC]), and then make connection with another service (List Display) running
    on port 3334 in different machine and retrieve the required list data. This program was working fine in almost all the machines.
    But, we have received a severe intermittent issue on two machines. Client is facing issue in displaying the list data from port 3334.
    Attempt: -
    First we tried to debug code, and we come to know that socket is not creating in utility program. So we tried to telnet on ListDisplay service port 3334 and we were surprised that we were able to telnet, then we opened some more
    telnet window on same port 3334 around (6 to 8) window, and each cmd connected properly. But we were not able to create socket from utility program.
    Problem is severe because issue is intermittent.
    We have tried all the way, but we are not able to figure it out, that what can be the exact problem and what are the conditions, when utility program will not
    connect with ListDisplay service on port 3334.
    Kindly assist to resolve this issue. For any help, we would be really thankful.

    Hi,
    According to your description, it seems that you have created an utility program which is making connection with another service port 3334, however, two clients are facing issue in display the data list from port 3334.
    Port: 3334/TCP
    3334/TCP - Known port assignments (1 record found)
    Service
    Details
    Source
    directv-web
    Direct TV Webcasting
    IANA
    Since the port 3334 is used by directv-web service, I'd like to suggest check this service it is working well on the problematic clients.
    1. The client can be resolved in DNS well? Please run "nslookup" in the prompt command.
    2. Is there any 3rd party application interrupting? Do test in clean boot.
    2. Strongly suggest you run process monitor tool to analysis it.
    I am looking forward to your reply if you have any updated on your side.
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • Problem with socket connection through Java Embedding...

    We are trying to create a simple socket connection to a socket server through BPEL PM using the Java Embedding component.
    BPEL Process : Client makes an asynchronous request. Passes an input variable. The input variable is sent to the Server Program through a socket connection through the Java embedding component.
    Server: We are running a simple Socket Server program from command prompt.
    The code below works fine as long as we do not try to receive a response from the server (Commented Code).
    If we uncomment the code and try to receive a response, it refuses to create an instance for the BPEL Process. And sometimes restarts the BPEL Server.
    Client Code:
    String msg="NONE";
    try{
    org.w3c.dom.Element input = (org.w3c.dom.Element) getVariableData("inputVariable","payload","/client:clientProcessRequest/client:input");
    msg = input.getNodeValue();
    Socket clientsoc=new Socket("ServerIP",1000);
    PrintWriter out1=new PrintWriter(clientsoc.getOutputStream());
    out1.write(msg);
    out1.flush();
    BufferedReader cin1=new BufferedReader(new InputStreamReader(clientsoc.getInputStream()));
    msg=cin1.readLine();
    setVariableData("outputVariable","payload","/client:result",new String(msg));
    clientsoc.close();
    catch(UnknownHostException e)
    System.err.println("Don't know about host: dev.");
    System.exit(1);
    catch (IOException e)
    System.err.println("Couldn't get I/O for "+ "the connection to: dev.");
    System.exit(1);
    }

    Repost

  • Connection problem odbc socket

    I made a odbc socket connection through a dsn to a foxpro
    database (tables), cf made the connection. Dreamweaver sees all of
    the tables, but cannot read the fields or data. Received this error
    message:
    [1]java.sql.SQLException: [Macromedia][SequeLink JDBC
    Driver][ODBC Socket][Microsoft][ODBC Visual FoxPro Driver]File
    'ccdllc.actrec' does not exist.
    even tho actrec was a listed table in the database panel.
    Any ideas?
    David

    Thanks for spending your time on this. I'm brand new on CF,
    have always used asp for database work, thought this would be a
    breeze. Clearly there's some simple thing I'm not doing correctly.
    I made the connection to the database in CF with the ODBC socket
    driver, then verified the connection. Went into Dreamweaver, set up
    the database connection, and read the table list in the database
    panel. But Dreamweaver wasn't able to read the contents of the
    tables (columns and data), nor was it able to make bindings. I
    inserted the query into the html page and tried running the code
    with the following results:
    -1:[Macromedia][SequeLink JDBC Driver][ODBC
    Socket][Microsoft][ODBC Visual FoxPro Driver]File 'ccdllc.actrec'
    does not exist.
    java.sql.SQLException: [Macromedia][SequeLink JDBC
    Driver][ODBC Socket][Microsoft][ODBC Visual FoxPro Driver]File
    'ccdllc.actrec' does not exist.
    at
    macromedia.sequelink.ssp.Diagnostic.toSQLException(Unknown Source)
    at macromedia.sequelink.ssp.Chain.cnvDiagnostics(Unknown
    Source)
    at macromedia.sequelink.ssp.Chain.decodeDiagnostic(Unknown
    Source)
    at macromedia.sequelink.ssp.Chain.decodeBody(Unknown Source)
    at macromedia.sequelink.ssp.Chain.decode(Unknown Source)
    at macromedia.sequelink.ssp.Chain.send(Unknown Source)
    at
    macromedia.sequelink.ctxt.stmt.StatementContext.execDirect(Unknown
    Source)
    at
    macromedia.jdbc.sequelink.SequeLinkImplStatement.execute(Unknown
    Source)
    at
    macromedia.jdbc.slbase.BaseStatement.commonExecute(Unknown Source)
    at
    macromedia.jdbc.slbase.BaseStatement.executeQueryInternal(Unknown
    Source)
    at macromedia.jdbc.slbase.BaseStatement.executeQuery(Unknown
    Source)
    at
    coldfusion.server.j2ee.sql.JRunStatement.executeQuery(JRunStatement.java:111)
    at
    coldfusion.rds.DbFuncsServlet$DbSqlStatementOperator.processCmd(DbFuncsServlet.java:409)
    at
    coldfusion.rds.DbFuncsServlet.processCmd(DbFuncsServlet.java:78)
    at coldfusion.rds.RdsServlet.doPost(RdsServlet.java:57)
    at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
    coldfusion.rds.RdsFrontEndServlet.doPost(RdsFrontEndServlet.java:102)
    at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
    coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:78)
    at
    jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
    at
    jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
    at
    jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257)
    at
    jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
    at
    jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
    at
    jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:318)
    at
    jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:426)
    at
    jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:264)
    at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
    Again, thanks for your help, looking forward to any ideas you
    might have.
    David

  • Howto connect with http to a socket - header problem?

    Hi
    i am writing a midlet that connects via http to a server with a java socket.
    i can receive the data, but when i try to return data to the sockets outputstream,
    the midlet doesnt receive it and waits endlessly.
    Do i have to send a http header in the return connection?
    Does anybody have another idea?
    if not, how do i send the header and how should it look like?
    Thanks for your help.
    Mathis

    if you use a socket connection you need to talk the language the server understands, means, you need to send the commands that are specified in the rfc for the protocol you use. means, talking to a webserver is different that talking to pop3 server or to a ftp server.....
    and, just for your information: sockets are not requiered in the j2me specification, means that not all vendors have implemented socket protocol into their devices. only required is http.

  • Having problems with shut-down of server after I open a socket connection (which fails to connect)

    Basically here is an example servlet - new iPlanet 4.1sp9 instance with an empty classpath (apart from the servlet class) - running solaris v5.6 (Generic_111446-02)
    If you run the servlet and then try to shut-down iPlanet it hangs. If you remove the 'new Socket(...' line then it's fine. Any ideas why a failed socket connection stops the server restarting? (Connecting to a listening port does not exhibit this behavior).
    Cheers, source follows:
    * SocketServletTest.java
    * Created on 02 April 2002, 09:30
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.net.Socket;
    * @author kingrb
    * @version
    public class SocketServletTest extends HttpServlet
    private static boolean startedThread = false;
    /** Initializes the servlet.
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    /** Destroys the servlet.
    public void destroy()
    /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException
    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();
    if (!startedThread)
    out.println("Starting thread");
    Thread t = new SocketThread();
    t.start();
    startedThread = true;
    out.println("Started thread);
    out.println("test");
    out.println("Prop is: " + System.getProperty("MyProp"));
    out.close();
    /** Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException
    processRequest(request, response);
    /** Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException
    processRequest(request, response);
    /** Returns a short description of the servlet.
    public String getServletInfo()
    return "Short description";
    private class SocketThread extends Thread
    public void run()
    int counter = 0;
    String errMsg = null;
    while (1==1)
    counter++;
    Socket s = null;
    try
    s = new Socket("127.0.0.1", 27087);
    s.close();
    catch(Exception e)
    errMsg = e.getMessage();
    if (s != null)
    errMsg += " & NOT NULL";
    try
    {s.close();} catch(Exception e2)
    System.setProperty("MyProp", String.valueOf(counter) + " - " + errMsg + "<BR>" + System.getProperty("java.class.path"));
    try {Thread.sleep(30000);} catch(Exception e) {}
    }

    Rob:
    it's due to JVM signal handler that catches the stop signal and you're forced to use a kill -9 -
    Note that the stop script of a fresh install of iWS 4.1SP9 should contain the kill -9 - as a workaround for this known JVM issue.

  • Unending connectivity problems -- and Desktop Help...

    I'm wasting so much time on connectivity problems that it's positively wearying. Prior to the installation of BT Infinity here in April, I had a low quality broadband service because of the length of the line from the exchange: if I could get a download speed of 1.2Mbps and an upload of a quarter of that, I was doing well. 
    BT advised that thanks to fibre optic, my Internet should run much faster. So we had Infinity installed. I'm registered with Speedtest.net so am able to see my performance record.
    The average download speed is now aroun d 6Mbps and the average upload, more than that at 7Mbps. How an upload speed can consistently be faster than a download escapes me.
    But I'm not familiar with the ways of Internet connectivity and try as a I might, can't get my head around it.
    This desktop computer runs Vista OS. Vista was **bleep** when it came out and is renowned for its botched handling of Internet connections. So I'm not blaming BT for the literally unending connectivity problems that are occurring now, with line drops, speeds slowing to a crawl, and no guarantee that any connection will last. But it would be good to actually use BT software to help fathom out what's going wrong here, and today's typical morning which looks like this:
    1) Boot up computer. Automatic connection to hub via Netgear USB wireless adapter. Hub is on ground floor of this 3-storey property but signal strength from hub  is excellent, as confirmed by inSSIDer monitoring, currently showing 54 with no other networks anywhere near that figure.
    2) Perhaps 5 minutes after connection established, it's then lost. 'Local Only' is displayed. This is, apparently, a known Vista problem. But Microsoft has issued a fix for it. I know this, because it took 100 hours of ploughin g the Net to find out that MS had finally admitted to one more Vista screw-up. I've used the Microsoft router "fix it" before and it didn't work ("failed to process") so uninstalled it and have DL'd it again now and run it. This time it says it has fixed everything.
    3) Computer is re-booted to make the fix effective. Computer connects to Internet. Speedtest.net check yet again confirms that upload speed is faster than download speed.
    4) Connection dies. So much for Microsoft Fix It.
    5) Windows diagnostics reports that it can re-set the IP profile (or something.) I click yes. The re-set goes through. Connectivity is restored. 10 minutes later, connectivity is lost. Just a red X in the tray. No connection of any kind, not even that daft 'Local Connection' only alert.
    6) Reboot. Yet again. BT Desktop Help was installed here and ran OK when we were using our Netgear DSG34 router. But since the change to the BT Hub, the BT program has never run at all. So-oo. . . It has been uninstalled. And then re-DL'd and re-installed. And though the installation  has been completed, clicking on 'launch' has failed to launch anything. But anyway. An hour ago, in one of the brief periods today when the Internet connection was holding up, I Revo-ed out the earlier install, DL'd BT desktop Help and re-installed it. . . and I'm still at the same stage as always, with a  Firefox browser page that's open and completely blank and has been for the past 30 minutes. The URL is:
    file:///C:/Program%20Files/BT%20Broadband%20Desktop%20Help/btbb/Start.html
     Repeated page re-loading gets nowhere. Malwarebytes PRO is turned OFF to prevent any possibility of blocking and the antivirus is termporaily SUSPENDED. This PC runs on Windows standard firewall but even turning that OFF doesn't get the page to load. Copying the address into Internet Explorer in case there's a Firefox problem merely results in Firefox being opened and the same blank page running there.
    7) After all that. . . Connection lost yet again and this time, Windows cannot connect at all. It reports that the "wireless network security key is not correct". I happen to know that it is, because this is maybe the 20th time it has reported this in the past 10 days and every time I have to key in the "correct" key all over again. . . at which point Windows still says it isn't correct and cannot repair.
    Turning off the computer completely, unplugging from the wall, holding in the power switch for a full minute to clear the circuits, traipsing up and dowen three flights of stairs to turn off the hub, then wait, then turn the power back onm again. . . Ah, wot fun times I'm having here with my particular versioin of Infinity (as in, an infinity of connectivcity problems.)
    Summary: I seem to be being simultaneously hit with one issue after another.
    I'm bewildered as to why ever since Infinity was installed here, my upload speed is generally faster than my download speed. I'm not happy with endless Internet connection failures though am thinking that Vista is playing a large part here with its "wrong security key" and unending 'Local Only / Limited Connection' failures. I do miss my Netgear router and the ability to access a fantastic help menu and re-boot directly from the desktop without having to keep going up and down three flights of sdtairs to do so (I haven't been able to find out how toe access the BT Hub remotely.)
    Above all though: I'm  really tired of repeatedly trying to run freshly downloaded and installed BT Desktop Help software but getting no further than a blank page because the program has stalled.
    If anyone has any advice / suggestions, other than to buy a carrier pigeon, that'd be much appreciated.
    Thanks.

    Thanks again to John and gg30340. Here's an update:
    1) BT Desktop Help removed completely from this computer. The uninstaller itself mopped up everything, which surprised me. But anyway.
    2) Bt Home Hub manager set up and working. Had to input serial number and create new password. All of this sounds fairly easy and would be if one had the device near the desk. But the idiots who built this property shoved the BT master socket inside the garage next to the door. Our two home computers are on the third floor. To ensure the wireless signal strength is OK, the Hub and Infinity module/device/whatever it's called are on a high shelf. It's a major job to even reach the darn things, never mind read the labels seeing as how the BT Infinity engineer was good enough to tidy up the cabling and make a very tight connection to the wall socket.
    3) I had hoped to be able to back up the Hub's settings, seeing as the software provides for Advanced Settings / System / Backup. But not on mine (Hub 3.0). All that System allows is choosing which internet clock to define the accurate time. Everything else in System is just a pattern of short lines as if trying to indicate that there's some text there but it's invisible.This is now my second encounter with BT software which, for whatever reason, isn't functioning as it should on this PC.
    4) Hub reset to factory fresh, according to BT guide.
    5) Reset appears to have achieved nothing apart from requiring the password to be popped in again. After reset, it wasn't even possible to connect to the hub manager. Internet connectivity was eventually established for all of 30 seconds and then, gone.
    6) Computer was shut down and then booted anew. Internet connectivity is still. . . dreadful. One minute everything's fine and then, literally,. the next minute a webpage won't load. Even opening the Hub Manager has taken three attempts, i.e., disconnecting from the Internet, re-connecting, failing, and trying twice more until success. Yet all the time these failures are occurring, the tray icon is showing a steady, unwavering green icon for Local and Internet access -- despite the fact, there manifestly isn't any.
    7) Speedtest. net tests are actually showing upload and download 'trajectories' going slower and slower and finally halting at some point on the arc, then after a period of up to 30 seconds, suddenly becoming animated again. Speed test results with broadband speed checker UK and Think Broadband's checker are so at variance with one another, and with Speedtest, net, that it seems all three are using different technologies in pursuit of the same thing. Either way, upload speeds continue to be much, much faster than download speeds, a state of affairs I certainly have never encountered before.
    8) Speedtest net tests taken in the past 10 minutes, with one test following on from its predecessor, begin at 8.24 down/8.88 up, followed by 5.24 down / 6.40 up, followed by a mind-numbingly lonnnnng 0.62 down / 8.70 up -- in other words, a continuous yo-yoin g of Internet connectivity to the pooint that it actually might as well not even be here (I've had to make five attempts just to get on to this forum. . .)
    9) BT Speedtest will necessitate disconnection of everything downstairs and all boxes being lugged up here. This is actually going to require uncoililng tied-off cabling and hanging off a stepladder to do so -- though I surely can't be the only person in Britain who doesn't have a nice, handy BT master socket in their study or lounge. That said though: until we switched to Infinity, we *never* experienced these kinds of horrendous connectivity problems and never had need to unplug the Netgear router downstairs and bring it upstairs to connect directly to tjhe desktop PC so BT's own test could be run.
    I'll just have to get to work dismantling stuff tomorrow. However, I have to say that after a factory re-set which has changed nothing at all, I'm beginning to think there's a problem with the BT line itself (hence why I'm happy to follow the advice here, though less than happy at the prospect of the messing about involved.)
    Thanks, you two, for your patient help, and also for clarifying the situation re the three signal paths being shown on inSSIDer. At least I know that's usual now! And now, hopefully, when I press 'Post', I won't be faced with an endlessly spinning Firefox circle culminating in  what may well be, or seem to be, the 57,938th time today of seeing "Page Not Found". . .

  • Connection Problem while client is behind proxy and server out side proxy

    hello
    i implemented ChatApplication in JAVA, for that i used socket connection when client and server both are in same network then it's working fine.
    but when my server is on internate and client is behind proxy and try to connect with server
    it not able to connect i get exception.
    i serch most of forum i got same answer and i try it but i was not success.
    any kind of help is appriciated.
    i attached my code(which i implement for testing ) pls reply me
    thanks in advance.
    Server.java
    import java.lang.*;
    import java.io.*;
    import java.net.*;
    class Server {
       public static void main(String args[]) {
          String data = "you are successfully connected with server.";
          try {
             ServerSocket srvs = new ServerSocket(1234);
             Socket skt = srvs.accept();
             System.out.print("Server has connected!\n");
             PrintWriter out = new PrintWriter(skt.getOutputStream(), true);
             System.out.print("Sending string: '" + data + "\n");
             out.print(data);
             out.close();
             skt.close();
             srvs.close();
          catch(Exception e) {
             System.out.print("Whoops! It didn't work!\n");
    ProxyClient.java
    import java.io.*;
    import java.net.*;
    import java.util.*;
    class ProxyClient{
       public static void main(String args[]) {
         String host="61.17.212.29";
         int port=1234;
               String line;
         Properties properties = System.getProperties();
         /*properties.put("firewallSet", "true");
         properties.put("firewallHost", "192.168.0.1");
         properties.put("firewallPort", "808");*/
         properties.put("socksProxySet","true");
         properties.put("socksProxyHost", "192.168.0.1");
         properties.put("socksProxyPort", "1080");
         System.setProperties (properties);
         try {
         /*SocketAddress addr = new InetSocketAddress("192.168.0.1", 1080);
         Proxy proxy = new Proxy(Proxy.Type.SOCKS, addr);
         Socket skt = new Socket(proxy);
         InetSocketAddress dest = new InetSocketAddress("61.17.212.29",1234);
         skt.connect(dest);*/
             System.out.println("before socket taken");
             Socket skt = new Socket(host,port);
             System.out.println("after socket taken");
             BufferedReader networkBin = new BufferedReader(new InputStreamReader(skt.getInputStream()));
             System.out.println("Received string: '");
             line = networkBin.readLine();     // Read one line
          while(true)
                 System.out.println(line);     // Output the line
                 line = networkBin.readLine(); // Read the next line, if any
          catch(Exception e) {
             System.out.print("Whoops! It didn't work!\n");
         e.printStackTrace();
    }

    Now look here. I could not care less about this
    code. I don't know anything about it, I don't
    want to know, I have already recommended you don't
    use it, and I have also given you a simpler and
    better solution. If you don't want to take my advice
    that is your privilege and your problem.ya i has understand system propertis i have setted and u can see it in the code i have tried by both system properties and also J2SE 5.0 proxy class but i got a same problem malformed Exception server refuse to connection.
    is there any problem at sever side?
    can u tell me in which way u r teling to set the propery i m looking forward for ur reply.
    ya i m sure u will give me.................reply "ejp".
    Thnx in advance.

  • Content Server connection problems

    SAP Content Server connection problems
    I have installed the SAP Content Server on a Windows 2003 server. I connected to the Max DB on the remote server from Database Manager on my PC. I created repositories in R/3 in OAC0 and CSADMIN and saved documents to the Content Server. This all took a few hours from O/S install to saving a document in the repository, so I do understand the basics of the Content Server and Max DB.
    Unfortunately we are not going to use Windows; we will be running this on UNIX. Therefore I'm trying it out on a Linux system while I wait for the AIX system to be available. It's been a long road but I have finally gotten the install to finish 'successfully' however I can't connect from R/3.
    When I run the check http://10.XXX.YYY.ZZZ:1090/ContentServer/ContentServer.dll?serverInfo from the browser on the Linux host I get back a good status as shown below:
    serverType="SAP HTTP Content Server";serverVendorId="SAP AG";serverVersion="640";serverPatch="0";serverBuild="16";pVersion="0046";serverStatus="running";serverDate="2008-03-25";serverTime="22:39:45";startUpDate="2008-03-25";startUpTime="22:32:21";lastAccessDate="2008-03-25";lastAccessTime="22:38:33";
    However when I do this from any my PC it won't connect. (Of course the real problem is I can't connect from R/3.)
    If I try the same URL from a different user session on the same Content Server Linux host I get the same good status.
    I thought maybe the httpd.conf file was wrong so I tried:
    Listen 0.0.0.0:1090
    In cs.conf I tried commenting out AdminSecurity & AdminSecurityGroup.
    I also changed StorageDriver from SAPDBStorage to FSStorage.
    I don't know if this is related or just another problem to tackle once I can get through this one. I was not able to add the new system to the Database Manager. I get the error "-4 could not connect to socket [10060]".
    Thanks to all for any help. Points will dutifully be rewarded.
    David

    Hi Henk,
    It looks like I am dumber than a rock. The firewall was indeed active on the Linux host. I turned it off and can now do the http connection test to the Content Server. (I awarded very helpful points.)
    I still can't connect to the database with the Database Manager however the message has changed; it now says "-4 XSERVER might be inactive". I just turned off the firewall so I have a few things to try, like figure out how to start MaxDB without the DB Manager. I'll post my progress. Thanks Henk.
    David
    Edited by: Dave Hill on Mar 28, 2008 12:00 AM
    Now I have installed the Database Studion on my PC. No I'm getting this message when I try to connect to the host/database on the Linux system: "Cannot connect to host 10.XXX.XXX.XXX:7210 [Connection refused: connect], -813."
    Does MaxDB need to be started to connect? Any idea how to start it manually? Thanks,
    David
    Edited by: Dave Hill on Mar 28, 2008 1:06 AM
    Ah, at long last. There's this tiny yet very important little program called x_server that SAP didn't include in the SAP Content Server install guide. This needs to be running in order for anything to connect. I'm sure most of you know about it but for the rest you can find it in:
    /sapdb/programs/bin
    Then type
    ./x_server start
    I'm not sure what user it should run under but I started it as the sdb user.
    You could automate the database startup with a script. See http://maxdb.sap.com/doc/7_7/e9/005dac1592496783e26133eb7fad0b/frameset.htm
    Thank you Henk, I'll call this problem solved and award points.
    Edited by: Dave Hill on Mar 28, 2008 2:10 AM

  • TCP Socket connection in CLOSE_WAIT status and not getting closed

    I am facing an issue with the TCP socket connections not getting closed and they are in CLOSE_WAIT status for ever.
    As a part of batch process in our application, emails are sent with 4 embedded images. These images are downloaded from 3rd party site with IP say "UUU.XXX.YYY.ZZZ"
    The images are embedded to email as follows
    1. An URL object is created with the site url.
    URL urlPhoto = new
    URL("http://UUU.XXX.YYY.ZZZ/email/photos.jpg");
    2.     The image cid is created with the URL object and the image name
    HtmlEmail htmlEmail = new HtmlEmail();
    String cid1 = htmlEmail.embed(urlPhoto,
    "photo.jpg");
    3.     The image cid is added to the email template by replacing the ${cid1} and the email is sent.
    <td valign="top">
                   <img src="cid:${cid1}" width="279" height="274">
              </td>
    When a mail is sent, 4 new TCP connections are opened and are put in CLOSE_WAIT status for ever. For every mail sent 4 new connections are opened. In UNIX there is an upper limit on the number of open file handles (defaults to 1024) at any point of time. The open TCP connection has the underlying socket in CLOSE_WAIT status and is not getting closed at all. When the upper limit (1024) is reached the batch process is throwing the following exception and terminates.
    Caused by: com.inet.tds.ap: java.net.SocketExceptionjava.net.SocketException: Too many open files
    at com.inet.tds.am.a(Unknown Source)
    at com.inet.tds.TdsDriver.a(Unknown Source)
    at com.inet.tds.TdsDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(DriverManager.java:525)
    at java.sql.DriverManager.getConnection(DriverManager.java:171)
    at com.hcomemea.batchprocess.dataaccess.database.BaseJdbcDao.openConnection(BaseJdbcDao.java:106)
    ... 12 more
    When I run the command lsof in UNIX which list the open file handles in the system
    $ /usr/sbin/lsof -p 22933 -i | grep CLOSE_WAIT
    java 22933 build_master 297u IPv6 129841943 TCP integration.com:47929->UUU.XXX.YYY.ZZZ:http (CLOSE_WAIT)
    java 22933 build_master 298u IPv6 129841947 TCP integration.com:47933->UUU.XXX.YYY.ZZZ:http (CLOSE_WAIT)
    java 22933 build_master 299u IPv6 129841950 TCP integration.com:47936->UUU.XXX.YYY.ZZZ:http (CLOSE_WAIT)
    java 22933 build_master 300u IPv6 129841970 TCP integration.com:47952->UUU.XXX.YYY.ZZZ:http (CLOSE_WAIT)
    ���list of 935 connections similarly�
    I tried 2 solutions
    1. Got the HttpURLConnection from the URL object and invoked disconnect method on the same. But it doesn�t work.
    2. Ran the batch process java program with the parameter �Dhttp.keepAlive=false to close the underlying connection but didn�t help.
    I need the underlying sockets to be closed and not put in CLOSE_WAIT status after sending the mail.
    Is it the problem with the embed method of HtmlEmail object not closing the underlying socket connection.
    If anyone has faced this issue before, kindly let me know the possible solutions for the same ASAP.
    Thank you,
    Ramesh G

    This sounds more like a problem due to connection pooling at middle tier/application server.
    If that has been ruled out, then you might to enable DCD or set expiry time on the server.

Maybe you are looking for