Unexpected socket read timeout

Hi everybody.
I am having problems with socket communication. I have a client application which connects to a server, sends a request over a socket and waits for a response. This procedure actually works unless the server doesn?t reply fast enough. I found out that the maximum time for the server to reply is exactly 4 minutes. The weird part is that I do not set any timeouts.
I was able to isolate the problem and it turned out that the unexpected 4 minute timeout only occurs if I use the socket?s shutdownOutput method prior to reading from the input stream.
Does anyone know of this problem and how one can solve it? Or is this a (known) bug in the JDK?
Regards,
Kai

This is a simple server that listens for a one-line message ("HI") which will receive no response, and will then close the connection.
// don't forget to import
import java.io.*;
import java.net.*;
public class Server {
ServerSocket server;
Socket socket;
BufferedReader in;
PrintWriter out;
public Server() {
try {
// Note: No timeouts or linger options were set on THIS machine.
server = new ServerSocket(110); // We will use port 110 for our example
socket = server.accept();
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out = new PrintWriter(socket.getOutputStream());
String request = in.readLine(); // this method blocks (unless Java 1.4 is used and the Non-blocking option is set)
System.out.println(request);
in.close();
out.close();
socket.close();
server.close();
} catch(Exception e) {
e.printStackTrace(); // show the error
// add this is you want this to run as a stand-alone application
public static void main(String[] args) {
new Server();
The server starts, listens for connections, prints the 'request' to the console, and then closes the connection and the server is shutdown. There will be no problems since I DO NOT USE socket.shutdownInput()
Use my model code here to by-pass the issue you are having.

Similar Messages

  • Create the ODBC for OBIEE -[nQSError: 12017] Unexpected socket read timeout

    Hello Friends,
    I have installed OBIEE 11.1.1.7 on vmware on my laptop. Im able to communicate via putty and local browsers successfully to all of the logins (console,em, analytics, bipublisher, etc.)
    Now when i'm trying to create the DSN connection from setup odbc.
    I'm getting the error as mentioned in subject.
    Firewall of my laptop is off. IPTables of my linux OS is disabled.
    analytics poet is 9704.
    Screenshot is attached herewith.
    Please help me in sorting this issue.
    Regards,
    Djay

    Hi Srini,
    I crosschecked it earlier only and both the tests were successful.
    ping obiee.oracle.com : is able to connect.
    telnet obiee 9704 : Shows blank screen.
    I'm just stucked in troubleshooting and dont know what to do !
    Regards,
    Djay

  • Unable to read field value from main table - unexpected socket read error

    Hi Friends,
    While executing the below code, I am able to get the value of the field 'id' but i am unable to get the value for the 'materialnumber' field. i am getting the below exception
    +com.sap.mdm.commands.CommandException: com.sap.mdm.internal.protocol.manual.ProtocolException: java.io.IOException: Unexpected socket read.  Result is -1.
         at com.sap.mdm.data.commands.AbstractRetrieveLimitedRecordsCommand.execute(AbstractRetrieveLimitedRecordsCommand.java:158)
         at com.sap.mdm.data.commands.RetrieveLimitedRecordsCommand.execute(RetrieveLimitedRecordsCommand.java:157)
         at updaterecords.main(updaterecords.java:126)
    Caused by: com.sap.mdm.internal.protocol.manual.ProtocolException: java.io.IOException: Unexpected socket read.  Result is -1.
         at com.sap.mdm.internal.protocol.manual.AbstractProtocolCommand.execute(AbstractProtocolCommand.java:100)
         at com.sap.mdm.data.commands.AbstractRetrieveLimitedRecordsCommand.execute(AbstractRetrieveLimitedRecordsCommand.java:146)
         ... 2 more
    Caused by: java.io.IOException: Unexpected socket read.  Result is -1.
         at com.sap.mdm.internal.net.DataSocket.receiveData(DataSocket.java:59)
         at com.sap.mdm.internal.net.ConnectionImpl.readInt(ConnectionImpl.java:417)
         at com.sap.mdm.internal.net.ConnectionImpl.nextMessage(ConnectionImpl.java:501)
         at com.sap.mdm.internal.net.ConnectionImpl.receiveMessage(ConnectionImpl.java:472)
         at com.sap.mdm.internal.net.ConnectionImpl.send(ConnectionImpl.java:209)
         at com.sap.mdm.internal.net.ReservedConnection.send(ReservedConnection.java:105)
         at com.sap.mdm.internal.protocol.manual.AbstractProtocolCommand.execute(AbstractProtocolCommand.java:97)
         ... 3 more+
    import com.sap.mdm.commands.AuthenticateUserSessionCommand;
    import com.sap.mdm.commands.CommandException;
    import com.sap.mdm.commands.CreateUserSessionCommand;
    import com.sap.mdm.commands.DestroySessionCommand;
    import com.sap.mdm.commands.GetRepositoryRegionListCommand;
    import com.sap.mdm.data.Record;
    import com.sap.mdm.data.RegionProperties;
    import com.sap.mdm.data.ResultDefinition;
    import com.sap.mdm.data.commands.RetrieveLimitedRecordsCommand;
    import com.sap.mdm.ids.TableId;
    import com.sap.mdm.net.ConnectionException;
    import com.sap.mdm.net.ConnectionPool;
    import com.sap.mdm.net.ConnectionPoolFactory;
    import com.sap.mdm.schema.FieldProperties;
    import com.sap.mdm.schema.RepositorySchema;
    import com.sap.mdm.schema.commands.GetFieldListCommand;
    import com.sap.mdm.schema.commands.GetRepositorySchemaCommand;
    import com.sap.mdm.search.Search;
    import com.sap.mdm.server.DBMSType;
    import com.sap.mdm.server.RepositoryIdentifier;
    public class updaterecords {
         public static void main(String[] args) {
              try {               
                    String serverName = "159.112.6.26";
                    ConnectionPool connections = null;
                    try {
                         connections = ConnectionPoolFactory.getInstance(serverName);
                    } catch (ConnectionException e) {
                         e.printStackTrace();
                         return;
                   // specify the repository to use
                   // alternatively, a repository identifier can be obtain from the GetMountedRepositoryListCommand
                   String repositoryName = "DEMO";
                   String dbmsName = "MDMD";
                   RepositoryIdentifier reposId = new RepositoryIdentifier(repositoryName, dbmsName, DBMSType.ORACLE);
                   // get list of available regions for the repository
                   GetRepositoryRegionListCommand regionListCommand = new GetRepositoryRegionListCommand(connections);
                   regionListCommand.setRepositoryIdentifier(reposId);
                   try {
                        regionListCommand.execute();
                   } catch (CommandException e) {
                        e.printStackTrace();
                        return;
                   RegionProperties[] regions = regionListCommand.getRegions();
                   // create a user session
                   CreateUserSessionCommand sessionCommand = new CreateUserSessionCommand(connections);
                   sessionCommand.setRepositoryIdentifier(reposId);
                   sessionCommand.setDataRegion(regions[0]); // use the first region
                   try {
                        sessionCommand.execute();
                   } catch (CommandException e) {
                        e.printStackTrace();
                        return;
                   String sessionId = sessionCommand.getUserSession();
                   // authenticate the user session
                   String userName = "meter1";
                   String userPassword = "meter1";
                   AuthenticateUserSessionCommand authCommand = new AuthenticateUserSessionCommand(connections);
                   authCommand.setSession(sessionId);
                   authCommand.setUserName(userName);
                   authCommand.setUserPassword(userPassword);
                   try {
                        authCommand.execute();
                   } catch (CommandException e) {
                        e.printStackTrace();
                        return;
                   GetRepositorySchemaCommand cmd=new GetRepositorySchemaCommand(connections);
                   cmd.setSession(sessionId);
                   try{
                        cmd.execute();               
                   }catch(CommandException e){
                        System.out.println(e.getLocalizedMessage());
                   RepositorySchema repsch=cmd.getRepositorySchema();
                   // the main table, hard-coded
                   TableId mainTableId = new TableId(1);     
                   // specify the result definition (what to retrieve); in this example, nothing
                   ResultDefinition rd = new ResultDefinition(mainTableId);
                   // select all records
                   Search search = new com.sap.mdm.search.Search(mainTableId);
                   //get fields
                   GetFieldListCommand getFieldListCommand = new GetFieldListCommand(connections);
                   getFieldListCommand.setSession(sessionCommand.getUserSession());
                   getFieldListCommand.setTableId(mainTableId);
                   try {
                        getFieldListCommand.execute();
                   } catch (CommandException e) {
                        System.out.println(e);
                   FieldProperties[] lookupFields = getFieldListCommand.getFields();
                   // add fields to records to retrieve
                   rd.addSelectField(repsch.getFieldId("Products","Id"));
                   rd.addSelectField(repsch.getFieldId("Products","MaterialNumber"));                              
                   // retrieve the records
                   RetrieveLimitedRecordsCommand limitingCommand = new RetrieveLimitedRecordsCommand(connections);
                   limitingCommand.setSession(sessionId);
                   limitingCommand.setResultDefinition(rd);
                   limitingCommand.setSearch(search);
                   //limitingCommand.setPageSize(2000);
                   try {
                        limitingCommand.execute();
                   } catch (CommandException e) {
                        e.printStackTrace();
                        return;
                   System.out.println("Record count is " + limitingCommand.getRecords().getCount()+"\n");
                   Record[] records=limitingCommand.getRecords().getRecords();
    System.out.println(records[0].getFieldValue(repsch.getFieldId("Products","Id"))+ " \n");
    System.out.println(records[0].getFieldValue(repsch.getFieldId("Products","MaterialNumber"))+ " \n");
                   // finally destroy the session
                   DestroySessionCommand destroySessionCommand = new DestroySessionCommand(connections);
                   destroySessionCommand.setSession(sessionId);
                   try {
                        destroySessionCommand.execute();
                   } catch (CommandException e) {
                        e.printStackTrace();
                        return;
              } catch (Exception e) {
                   System.out.println(e.getLocalizedMessage());
                   e.printStackTrace();
    Kindly let me know where i am going wrong. MaterialNumber field is a TEXT not a lookup table field.  Above fields are from the main table.
    Thanks,
    Raags

    Hi Friends,
    I got the solution. It was the error because of not having a the below statement.
    limitingCommand.setPageSize(1);
    As i havent used that statement, it was trying to get 1000 records, and i dont know exactly what makes this to get that error. Anyhow., As i want to use for updation, i cn live with one record.
    Thanks,
    Raags

  • Socket Read Timeout error in weblogic logs happening every 30 min

    One of my customer is getting Socket Read Time out error, when creating connection pool.
    java.sql.SQLException: Socket read timed out
         at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:74)
         at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:135)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:203)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:489)
         at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:439)
         at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:640)
         at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:205)
         at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
         at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:554)
         at weblogic.jdbc.common.internal.ConnectionEnvFactory.makeConnection(ConnectionEnvFactory.java:327)
         at weblogic.jdbc.common.internal.ConnectionEnvFactory.createResource(ConnectionEnvFactory.java:227)
         at weblogic.common.resourcepool.ResourcePoolImpl.makeResources(ResourcePoolImpl.java:1193)
         at weblogic.common.resourcepool.ResourcePoolImpl$ResourcePoolMaintanenceTask.timerExpired(ResourcePoolImpl.java:2451)
         at weblogic.timers.internal.TimerImpl.run(TimerImpl.java:273)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused By: oracle.net.ns.NetException: Socket read timed out
         at oracle.net.ns.Packet.receive(Packet.java:333)
         at oracle.net.ns.DataPacket.receive(DataPacket.java:94)
         at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:176)
         at oracle.net.ns.NetInputStream.read(NetInputStream.java:121)
         at oracle.net.ns.NetInputStream.read(NetInputStream.java:96)
         at oracle.net.ns.Packet.extractData(Packet.java:443)
         at oracle.net.ns.AcceptPacket.<init>(AcceptPacket.java:108)
         at oracle.net.ns.NSProtocol.setNetStreams(NSProtocol.java:697)
         at oracle.net.ns.NSProtocol.connect(NSProtocol.java:386)
         at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1088)
         at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:305)
         at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:642)
         at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:205)
         at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:554)
         at weblogic.jdbc.common.internal.ConnectionEnvFactory.createResource(ConnectionEnvFactory.java:227)
         at weblogic.common.resourcepool.ResourcePoolImpl$ResourcePoolMaintanenceTask.timerExpired(ResourcePoolImpl.java:2451)
         at weblogic.timers.internal.TimerImpl.run(TimerImpl.java:273)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Any suggestions?

    Could be a firewall rule terminating an idle connection?

  • Socket read() call returning before timeout.

    I have a couple of applications which use the following basic socket reading approach:
    Socket socket = new Socket("192.168.0.1", 54321);
    socket.setSoTimeout (5000);
    InputStream stream = socket.getInputStream();
    byte[] data = new byte[232];
    boolean done = false;
    while (!done) {
        int res= stream.read(data);
        if (res < data.length) {
            System.err.println ("Error reading packet data - not enough data received: "+ res);
        // process and output the data
    try { stream.close(); } catch (Exception e) {}
    try { socket.close(); } catch (Exception e) {}The problem I am having is that sometimes read(byte[]) returns a before the full array's worth of data has been read, and before a timeout has occurred. I never get a SocketTimeoutException, but I do get my debugging output. I have recorded the network traffic with a packet sniffer (Wireshark), and what I am seeing is that in the instances where the read returns prematurely, it stops at the end of a TCP packet. The rest of the data is in another packet that arrives shortly afterwords (~1.5 ms or less).
    I know that with normal (file) input streams, read can return whenever it wants regardless of how many bytes were read, however I was under the impression that network streams are supposed to block until all the data arrives (or a timeout occurs, if set). Is this incorrect?

    djpeaco wrote:
    I know that with normal (file) input streams, read can return whenever it wants regardless of how many bytes were readThat's correct and that's exactly the reason you see the behavior you see.
    however I was under the impression that network streams are supposed to block until all the data arrives (or a timeout occurs, if set).Why? Why do you think that network streams behave differently in this regard?
    Why shouldn't it give you the data as soon as it's available, when every other stream works this way?
    Is this incorrect?Yes, you must assume that the streams of a socket follow the general InputStream/OutputStream contract and that includes possibly returning from read() before the full array is filled.

  • Read Timeout on non-blocking sockets

    Hi,
    I was wondering if there is a way to specify a read timeout (like setSoTimeout for synchronous sockets) when using a non-blocking socket.
    I'd like to have the select() method return is a sockets timeout expires, puting in the selected key set the timedout socket and have it's read operation return -1, something like what happens when a socket is closed by the other side.
    The thing is I need this to be a timeout specific to each socket, thus the select(millis) isn't apropriate.
    Anyone knows of something like this?
    Thanks....

    Yeah, select() is the only thing built in for that, and you have to do the bookkeeping yourself. You would start something like forming the disjunction of the ready keys and the registered keys after each select, to get the unready keys, and then looking at their history to see how long they have been unready via a Map{key,Long(time)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Socket read freezes on Linux despite timeout

    We're using Linux 2.6 multiprocessor machines and Sun JDK 6.
    Servers connect to each other over HTTP, setting socket timeout of 60 seconds.
    Despite that sometimes sockets freeze forever in read() operation.
    The code is like this:
    URL url = new URL(endpoint);
    URLConnection c = url.openConnection();
    c.setConnectTimeout( 60000 );
    c.setReadTimeout( 60000 );
    InputStream in = c.getInputStream();
    byte[] buffer = new byte[256 * 1024];
    int readBytes = -1;
    while ((readBytes = inputStream.read(buffer)) != -1) {
    // use remote data
    And the frozen stack trace is:
    java.net.SocketInputStream.socketRead0(Native Method)
    java.net.SocketInputStream.read(SocketInputStream.java:129)
    java.io.BufferedInputStream.read1(BufferedInputStream.java:256)
    java.io.BufferedInputStream.read(BufferedInputStream.java:317)
    sun.net.www.MeteredStream.read(MeteredStream.java:116)
    java.io.FilterInputStream.read(FilterInputStream.java:116)
    sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:2391)
    sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:2386)
    com.pmstation.shared.admin.core.MoveFile.pipeStream(MoveFile.java:189)
    com.pmstation.shared.admin.core.MoveFile.transferFile(MoveFile.java:173)
    Timeout not always working?
    So to be sure HTTP read from remote server is never blocking I'm forced to do IO on a separate thread? Or there are better ideas?

    Well then, it's important to note that a read timeout only specifies the amount of time to block while waiting for data. Once data has started to arrive, even one bit of data, the socket won't ever timeout because of a read timeout.
    I think I have a solution, however. Don't use the built-in timeout function, write a polling method that times out after so many seconds without receiving data.
    Try this ;-)
    URL url = new URL(endpoint);
    URLConnection c = url.openConnection();
    c.setConnectTimeout( 60000 );
    c.setReadTimeout( 60000 );
    InputStream in = c.getInputStream();
    byte[] buffer = new byte[256 * 1024];
    int readBytes = -1;
    /* Define our polling rates */
    int max_wait  = 60000; // 60 seconds
    int poll_rate = 2000;  // 2 seconds
    int last_amount;
    /* Poll for max_wait until we receive a full buffer */
    for (int i = max_wait; i > 0; i -= poll_rate) {
        /* Get the number of available bytes */
        int available_bytes = inputStream.available();
        /* Reset the poll if we are actively receiving bytes */
        if (available_bytes > last_amount)
         i = max_wait;
        /* Update the last amount variable */
        last_amount = available_bytes;
        /* Don't read until we have a full buffer or are about to timeout */
        if ((available_bytes < buffer.length) && (i >= poll_rate))  {
         Thread.currentThread.sleep(poll_rate);
        else if (available_bytes > 0) {
            /* Must have enough bytes or be last poll before the timeout */
            if ((readBytes = inputStream.read(buffer,0,available_bytes)) != -1) {
                /* Reset the last_amount variable */
                last_amount = 0;
                // use remote data
    }

  • Socket read error: connection reset by peer

    Hi.
    Has anybody experienced the error message �Socket read error: connection reset by peer�
    Please see below for detailed information.
    Appreciate your help
    Regards
    RT
    Enviroment specification
    Server: HP/UX 11.00 64-bit, Oracle RDBMS 8.1.6.0.0 64-bit
    2 firewalls between client and db.
    Client:
    Win 2000,
    SP3,
    Oracle Client 8.1.7.0.0 ,JDBC OCI (thin JDBC driver,class12.zip)
    JDK 1.3
    JRUN3.0
    The TCP protocol is being used in the communication
    Error messages
    Web Users receive:           Socket read error: connection reset by peer
    Trace files on the sever:      Read unexpected EOF ERROR on 18.
    Explanation: The error in the server sqlnet trace file, suggests that a client connection has terminated abnormally, i.e. client machine powered off, a cable removed or a network connection aborted without warning. No user has complained of such a problem and there is no client trace with an error.
    The problem
    The users of the java web application, experiencing an exception almost once or twice a day.
    The JRUN web-server reports broken connections to the db and client are receiving "connection reset by peer".
    At the moment when the errors occurs the users just have to wait a while(2-10 min) and then they can use the web application again.(no action is taken)
    This problem can not be reproduced. The problem happens only occasionally when the network is under heavy load and new DB connection is being created.
    The application
    The java web-application uses a customized connection pooling against the database. This pool is shared among all the users of the website. whenever a user process needs to fetch data from the database, a free connection from this pool is allocated. The application is testing if the connection is valid before making a transaction (select '1' from dual). When the error occurs a ORA-3113 end-of-file on communication channel is returned to the application.
    The path between the client and db involves at least two firewalls. The firewalls are opened for sql*net traffic. The network group can tell that enquiries from the app.server is not getting feedback from the db. They have not however, identified if the enquiries are reaching the db-srever, or if they are stopped earlier in the network.
    Around 1000 users, are using other applications which uses dedicated sqlnet connections against the db and they have not experienced any problems.
    Issues considered
    Connection pooling
    It is a customized connection pooling, developed by Lindorff developers.
    I have read through the source code for the connection pooling and it does the job as it should, and in case of bad connection, it tries to create a new connection.
    The log file shows that the call to the method DriverManager.getConnection() hangs until the server goes down, which is probably because of the fact that the method DriverManager.setLoginTimeout(), does not take effect and timeout value is Zero. ( According to oracle , Oracle JDBC does not support login timeouts and calling the static DriverManager.setLoginTimeout() method will have no effect).
    Firewall
    One thing to consider is when the firewall may decide to shut down the socket due to long inactivity of a connection. This will cause problems to JDBC Connection Pool because the pool is not aware of this disconnection at the TCP/IP level; until someone checks out the connection from the pool and tries to use it. The user will get a Socket read error: connection reset by peer.
    Jrun timeout paramter is less than the firewall�s timeout so the firewall will not close a connection before Jrun does.
    Number of processes the DB can handle
    Processes parameter is 1300, , they have not experienced the Oracle error msg �max # of processes reached�.
    Port redirection through a firewall:
    Since the firewall has a sql net proxy Port redirection through a firewall is not a problem. Problems with port redirection only appear at connect time, but in this situation the connections fail long after the connection is established.
    The network group
    The network people who investigaged the problem at Lindorff report that there are a significant amount of "dropped packages" between the database server and the jdbc client (web-application) 24 hrs. The reason for this is "unknown established TCP packet" which means that the firewall does not consider these packages to be part of an already established session. The network group believes this happen because one of the hosts send a RESET or FIN signal which the firewall have noticed but are not received by the other host.
    It seems like the firewall are dropping packages bacause of "Unknown
    established TCP packet" from both the JDBC client and the TNSLISTENER on the database server. The dropped packages are SQL*Net v2 traffic so clearly Oracle products are involved

    Presumably something is working.
    Thus the problem is not with your code. At least not the database part that you have control over.
    That error occurs when the other side closes the socket. Presumably you are catching lost connection exceptions and trying to restore it.

  • JDBC pooling Oracle driver Socket read timed out

    I run Java EE application on Glassfish server v3 together with Oracle 12 DB on the same machine under Windows Server 2012 64bit. I use latest ojdbc7 driver.
    Connection pool config:
      <jdbc-connection-pool validation-table-name="DUAL" steady-pool-size="20" statement-cache-size="100" associate-with-thread="true" statement-timeout-in-seconds="30" idle-timeout-in-seconds="60" max-wait-time-in-millis="2000" validate-atmost-once-period-in-seconds="20" datasource-classname="oracle.jdbc.pool.OracleDataSource" pool-resize-quantity="5" max-pool-size="60" res-type="javax.sql.DataSource" name="dbPool" is-connection-validation-required="true">
      <property name="driverClass" value="oracle.jdbc.OracleDriver"></property>
      <property name="user" value="xxx"></property>
      <property name="url" value="jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl)))"></property>
      <property name="password" value="xxx"></property>
      <property name="portNumber" value="1521"></property>
      <property name="databaseName" value="orcl"></property>
      <property name="serverName" value="127.0.0.1"></property>
      <property name="oracle.jdbc.ReadTimeout" value="300000"></property>
      <property name="oracle.net.CONNECT_TIMEOUT" value="10000"></property>
      </jdbc-connection-pool>
    After 2 or 3 hours, when there is more than 1 user (3-5) using my application, it stops responding and I get this in glassfish logs
      javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.allocator|_ThreadID=152;_ThreadName=Thread-2;|RAR5038:Unexpected exception while creating resource for pool dbPool. Exception : javax.resource.spi.ResourceAllocationException: Connection could not be allocated because: IO Error: Socket read timed out
      Local Exception Stack:
      Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
      Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: IO Error: Socket read timed out
    From the database side it looks like this
    Fatal NI connect error 12560, connecting to:
      (LOCAL=NO)
      VERSION INFORMATION:
      TNS for 64-bit Windows: Version 12.1.0.1.0 - Production
      Oracle Bequeath NT Protocol Adapter for 64-bit Windows: Version 12.1.0.1.0 - Production
      Windows NT TCP/IP NT Protocol Adapter for 64-bit Windows: Version 12.1.0.1.0 - Production
      Time: 13-JUN-2014 03:14:49
      Tracing not turned on.
      Tns error struct:
      ns main err code: 12560
      TNS-12560: TNS:protocol adapter error
      ns secondary err code: 0
      nt main err code: 0
      nt secondary err code: 0
      nt OS err code: 0
      opiodr aborting process unknown ospid (3404) as a result of ORA-609
    When I just reset db listener everything works ok for next 1-2 hours (depends on application load). So temporary solution is to run bat script from windows scheduler to reset the listener every 1h.
    I tried everything I could find - applied these parameters:
      - Sqlnet.ora:
      SQLNET.INBOUND_CONNECT_TIMEOUT=180
      SQLNET.EXPIRE_TIME=5
      - Listener.ora:
      INBOUND_CONNECT_TIMEOUT_LISTENER_IPC=120
    But still without success

    Is the problem here just that you need a connection pool that closes idle connections?  Some pools will close idle connections after a time out period.  And the pool lets you set that time out period.  If the pool you are using doesn't provide that then use a different pool.

  • Socket read fails but write is successful. Why?

    Hi once more!
    I have a Java application, reading and writing from/to a client socket:
    InputStream is = socket.getInputStream();
    BufferedReader br = new BufferedReader(new InputStreamReader(is));
    i = br.read();
    ...If i is equal to -1, it means there's no connection or that somehow the connection is unavailable right? So, how come is it possible to write to the socket's output stream with success after that read( ) returning -1? Shouldn't it also fail?
    I'm trying a "persistent" TCP connection, so I use that condition (read () == -1) to determine when the connection is down (read() is only blocking a certain amount of time).
    Thanks!

    I suggest you to have a process constantly
    sending a byte just to check that you still have
    the ability to send a packetNow you've got it.That's what I'm doing, yet I feel in my case it's not enough.
    I communicate with the server asynchronously. I send packets.. somewhen the server sends packets to my client.
    This way, I have to be continuously reading from the socket's Input Stream, in order to check for incoming packets (which may arrive at any time)... Thus, I have to be sure I can read from the socket..
    As the connection may timeout (if neither my client nor the server write anything to the socket) I send a dummy packet once per minute.
    However:
    1) This is too long to check connection status (only 1 time each minute)
    2) It doesn't tell me I can read ok from the socket - check the case where I could write but read ( ) returned -1. This is abnormal behaviour in my case.. do you think if the server was sending some packets, my read ( ) would be able to capture them (even after returning -1 for quite a while)? It seemed to me I was able to send, yet unable to receive.. or my packets weren't actually reaching the server even though they seemed to be.
    What write does is cause packets to be sent which
    require acknowledgement, and if the ACKs don't
    arrive, eventually a subsequent write() will fail. A
    read doesn't engage in any wire protocol at all,
    which is why it can't be used to detect a connection
    failure other than via a read timeout, or as a result
    of prior writes.Why does write ( ) doesn't fail when I unplug the cable? Either way this situation isn't quite important, as long as my packets start actually reaching the server after the cable is plugged back in. Curious, however, how write ( ) doesn't fail..

  • PROTOCOL_ERROR line 627 of URL.cpp unexpected EOF reading HTTP status

    Hello,
    I'm having a problem getting the NSAPI plugin talking with the WLS6.1sp3 Application
    server.
    The iPlanet Server logs the error:
    *******Exception type [PROTOCOL_ERROR] raised at line 627 of URL.cpp
    Thu Oct 31 10:20:03 2002 got exception in sendRequest phase: PROTOCOL_ERROR [line
    627 of URL.cpp]: unexpected EOF reading HTTP status at line 1048
    Thu Oct 31 10:20:03 2002 Failing over after sendRequest exception
    The Application Server logs:
    <Oct 31, 2002 10:20:03 AM MST> <Error> <HTTP> <Connection failure
    java.lang.NullPointerException
    at weblogic.servlet.internal.ServletRequestImpl.setField(ServletRequestImpl.java:1733)
    at weblogic.servlet.internal.RequestParser.parse(RequestParser.java:254)
    at weblogic.servlet.internal.MuxableSocketHTTP.dispatch(MuxableSocketHTTP.java:355)
    at weblogic.socket.PosixSocketMuxer.deliverGoodNews(PosixSocketMuxer.java:455)
    at weblogic.socket.PosixSocketMuxer.processSockets(PosixSocketMuxer.java:384)
    at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:24)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    Thanks in advance!
    Steve

    FYI, this was determined to be a bug in WebLogic 6.1sp3. BEA provided us with a
    patch.
    "Steve Wall" <[email protected]> wrote:
    >
    Hello,
    I'm having a problem getting the NSAPI plugin talking with the WLS6.1sp3
    Application
    server.
    The iPlanet Server logs the error:
    *******Exception type [PROTOCOL_ERROR] raised at line 627 of URL.cpp
    Thu Oct 31 10:20:03 2002 got exception in sendRequest phase: PROTOCOL_ERROR
    [line
    627 of URL.cpp]: unexpected EOF reading HTTP status at line 1048
    Thu Oct 31 10:20:03 2002 Failing over after sendRequest exception
    The Application Server logs:
    <Oct 31, 2002 10:20:03 AM MST> <Error> <HTTP> <Connection failure
    java.lang.NullPointerException
    at weblogic.servlet.internal.ServletRequestImpl.setField(ServletRequestImpl.java:1733)
    at weblogic.servlet.internal.RequestParser.parse(RequestParser.java:254)
    at weblogic.servlet.internal.MuxableSocketHTTP.dispatch(MuxableSocketHTTP.java:355)
    at weblogic.socket.PosixSocketMuxer.deliverGoodNews(PosixSocketMuxer.java:455)
    at weblogic.socket.PosixSocketMuxer.processSockets(PosixSocketMuxer.java:384)
    at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:24)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    Thanks in advance!
    Steve

  • WebLogic 11g data source connection pooling failed with IO error:socket read timed out.

    Hi all,
    We encountered IO Error: Socket read timed out( <Received exception while creating connection for pool "DS_1": IO Error: Socket read timed out> ) during the creation of data sources in WebLogic 11g. Manual data source testing seems to indicate intermittent connection and the server seems to take a long time to start up with multiple IO errors. We increased the timeout at the database side but it does not seems to help. The database is 11g (11.2.0.3). The database services and listener are up which does not indicate that the database instance is down.

    This particular error means your database is down and socket is timedout. Or the query takes so long that the reader timedout -- unlikely.
    Also, the general weblogic socket write errors, which you might see sometimes means that the client got disconnected before the server wrote results back. This is harmless

  • Socket write timeout

    How do you get a blocked write on a socket to timeout?
    I've written a simple test program that has two threads, one is the server that accepts a connection form the other that is the client. Once the client has established a connection, the server thread starts writing to the output steam of the socket. The client doesn't attempt to read any of the incoming data. I have set the SO_TIMEOUT option on the socket to 5 seconds. The server quickly fills the output buffer and blocks on the write call. And that's where is sits even after the 5 second timout has elapsed. I've tried a similar test on the read operation and the timeout works just fine.
    I'm using JDK 1.6.0_05.
    Any thoughts... am I missing something? Does the timeout only apply to the read operation and not the write?
    Thanks in advance.

    There isn't one. SO_TIMEOUT is a read timeout.
    Your only option is to use non-blocking NIO and a Selector and do the timing out yourself.
    If your writes are blocking it means the other end is slow reading, as you described.

  • Socket read time out

    Hi,
    A java class I use is connecting to another system via socket.
    This always works fine when using Java 1.3. However my database installation forces me to use Java 1.2.1 where the same code fails.
    Does anybody know of a workaround to this problem?
    I use Solaris.
    When using Java 1.2.1 I get
    Read timed out
    java.io.InterruptedIOException: Read timed out
    at java.net.SocketInputStream.socketRead(Native Method)
    at java.net.SocketInputStream.socketRead(Compiled Code)
    at java.net.SocketInputStream.read(Compiled Code)
    at java.net.SocketInputStream.read(Compiled Code)
    at java.io.InputStreamReader.fill(Compiled Code)
    at java.io.InputStreamReader.read(Compiled Code)
    at java.io.InputStreamReader.read(Compiled Code)
    at java.io.StreamTokenizer.read(Compiled Code)
    at java.io.StreamTokenizer.nextToken(Compiled Code)
    at com.posten.autent.AutentClient.receive(Compiled Code)
    at com.posten.autent.AutentClient.connect(AutentClient.java:265)
    Here is the code
    // Attempt to connect to server.
    try {
    socket = new Socket( host, port );
    in = new InputStreamReader( socket.getInputStream() ) ;
    input = new StreamTokenizer( in );
    output = new PrintStream( socket.getOutputStream() );
    input.resetSyntax();
    input.wordChars( '\u0021', '\uffff' );
    input.whitespaceChars( '\u0010', '\u0020' );
    input.whitespaceChars( '=', '=' );
    input.quoteChar( 39 );
    socket.setSoTimeout( timeout );
    catch( Exception e ) { ...
    The timeout is 10000 (10 seconds) which is far much more than necessary.
    Regards,
    Erika Biesse

    Well now, I've found a way around the problem myself.
    The java bug is Bug Id 4150737 and it was corrected in Java 1.2.2.
    The reason why I must stick to java 1.2.1 is that I call the java code from stored procedures in Oracle 8.1.7, which is JDK 1.2.1 compliant only. (If you the other way around call the OracleDB from java, you can use any java version.)
    Here is the WO:
    Before the very first input.nextToken I send an empty command, an extra
    newline.
    After each 'real' command I send, I call input.nextoken until TT_EOF or TT_EOL
    because the other system answers 'Error' on the empty command.
    Then I send another empty command, and then input.nextoken can read the answer
    of the 'real' command.
    Ugly, but it works!

  • Socket proxy timeout

    Hi,
    I'm currently using:
    mysock.connect(sockaddr, 2000);
    to set socket connection timeout.
    Everything works fine until i set a proxy:
    System.setProperty("socksProxySet", "true");
    System.setProperty("socksProxyHost", "proxy");
    System.setProperty("socksProxyPort", "port");
    Can i also set connection timeout for the proxy?

    ejp wrote:
    Oops I agree you are correct, it's there in 1.5 too. But does that propagate the 'closed' flag back to Socket?I think so, but I'm not sure. PlainSocketImpl extends SocketImpl. SocketImpl has a reference to the Socket, and close in PlainSocketImpl has this comment:
    * We close the FileDescriptor in two-steps - first the
    * "pre-close" which closes the socket but doesn't
    * release the underlying file descriptor. This operation
    * may be lengthy due to untransmitted data and a long
    * linger interval. Once the pre-close is done we do the
    * actual socket to release the fd.
    */It's hard to see if it call close on the Socket since socketPreClose and socketClose invokes native methods.

Maybe you are looking for

  • Win 8.1 Pro dism /Online /Cleanup-Image /RestoreHealth returns Error: 14098

    I am running Windows 8.1 Pro and have recently been experiencing some odd behavior.  This has lead me to discover that my component store is corrupt. I have attempted to use sfc with no luck and have posted that on a separate thread. When I attempt t

  • How do I access a value of a variable in SSIS and control the flow accordingly based on its value?

    So I have a Foreach Loop Container that Enumerates a read Excel spreadsheet and this Foreach Loop get its User::SheetName. Can I change my flow accordingly based on the value of the User Variable User:SheetName that is dynamically valued by the Forea

  • Problem with fileadapter

    Hi, I want to convert a xml-file into a txt-file with follow structure: Source_value_1a;source_value_2a;source_value_3a Source_value_1b;source_value_2b;source_value_3b Source_value_1c;source_value_2c;source_value_3c follow error appeares in the messa

  • AIR captive runtime

    Hi folks, was wondering if an app (Android) generated with captive runtime, still ask the user to install AIR plugin. If somebody knows ( and maybe have an example actually on market ) , i'll be glad to pay him/her a beer ! Thanks in advance

  • Re: My subscription not working

    Hi Everyone, I hope I'm in at the right place to ask, because I have an issue with my limited subscription. I have used up all of my minutes, and I just bought a Skype Credit. But on my account the 1 subscription says I still have 0 minutes left, whi