1 Reply Latest reply on Aug 10, 2007 1:49 AM by ron_sigal

    Closing the socket connection and sending multiple responses

    cazuza

      Please I need help,

      Appologies in advance if the questions are too naive, but I'm just starting with Jboss and have a head full of doubts.

      I have try to implement a socket server using jboss remoting and have hit a wall.
      the timeout attribute works but doesn't close the socket instead it sends error messages to the console.

      16:05:52,492 ERROR [STDERR] java.net.SocketTimeoutException: Read timed out
      16:05:52,492 ERROR [STDERR] at java.net.SocketInputStream.socketRead0(Native Method)
      16:05:52,492 ERROR [STDERR] at java.net.SocketInputStream.read(SocketInputStream.java:129)
      16:05:52,492 ERROR [STDERR] at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:411)
      16:05:52,493 ERROR [STDERR] at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:453)
      16:05:52,493 ERROR [STDERR] at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:183)
      16:05:52,493 ERROR [STDERR] at java.io.InputStreamReader.read(InputStreamReader.java:167)
      16:05:52,493 ERROR [STDERR] at java.io.BufferedReader.fill(BufferedReader.java:136)
      16:05:52,493 ERROR [STDERR] at java.io.BufferedReader.readLine(BufferedReader.java:299)
      16:05:52,493 ERROR [STDERR] at java.io.BufferedReader.readLine(BufferedReader.java:362)
      16:05:52,493 ERROR [STDERR] at com.xxxxx.dbi.socket.TextUnMarshaller.read(TextUnMarshaller.java:53)
      16:05:52,493 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.versionedRead(ServerThread.java:652)
      16:05:52,493 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:530)
      16:05:52,493 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:383)
      16:05:52,493 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)
      16:05:57,492 ERROR [STDERR] java.net.SocketTimeoutException: Read timed out
      16:05:57,493 ERROR [STDERR] at java.net.SocketInputStream.socketRead0(Native Method)
      16:05:57,493 ERROR [STDERR] at java.net.SocketInputStream.read(SocketInputStream.java:129)
      16:05:57,493 ERROR [STDERR] at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:411)
      16:05:57,493 ERROR [STDERR] at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:453)
      16:05:57,493 ERROR [STDERR] at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:183)
      16:05:57,493 ERROR [STDERR] at java.io.InputStreamReader.read(InputStreamReader.java:167)
      16:05:57,493 ERROR [STDERR] at java.io.BufferedReader.fill(BufferedReader.java:136)
      16:05:57,494 ERROR [STDERR] at java.io.BufferedReader.readLine(BufferedReader.java:299)
      16:05:57,494 ERROR [STDERR] at java.io.BufferedReader.readLine(BufferedReader.java:362)
      16:05:57,494 ERROR [STDERR] at com.xxxxx.dbi.socket.TextUnMarshaller.read(TextUnMarshaller.java:53)
      16:05:57,494 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.versionedRead(ServerThread.java:652)
      16:05:57,494 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:530)
      16:05:57,494 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:383)
      16:05:57,494 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)
      

      unless the client closes the connection itself it seems that the server will timeout and write error messages to STDERR. I don't want to rely on the client to close the connection, is it possible to close the socket connection after sending the response?

      the other question is How do I send multiple messages back to the client. At the moment on my invoke method I receive the request, parse it and return a string, what do I have to do to send another string without concatenating to the previous string? lets say I'm reading a huge file and want to send it line by line.

      here is my configuration file

      <server>
      <!-- ==================================================================== -->
       <!-- Invokers to the JMX node -->
       <!-- ==================================================================== -->
       <mbean code="org.jboss.remoting.transport.Connector"
       name="com.xxxx:service=Connector,transport=socket"
       display-name="RacingDB Socket transport Connector">
       <attribute name="Configuration">
       <config>
       <invoker transport="socket">
       <attribute name="timeout">5000</attribute>
       <attribute name="dataType" isParam="true">text</attribute>
       <attribute name="marshaller" isParam="true">com.xxxx.dbi.socket.TextMarshaller</attribute>
       <attribute name="unmarshaller" isParam="true">com.xxxx.dbi.socket.TextUnMarshaller</attribute>
       <attribute name="serverSocketClass">com.xxxx.dbi.socket.SimpleInputStreamWrapper</attribute>
       <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
       <attribute name="serverBindPort">6193</attribute>
       <attribute name="enableTcpNoDelay" isParam="true">true</attribute>
       </invoker>
       <handlers>
       <handler subsystem="RDBIS">com.xxxx.dbi.socket.Handler</handler>
       </handlers>
       </config>
       </attribute>
       </mbean>
      
      </server>