Re: [xSocket-develop] Trying to implement a Dual Port Server with XSocket
Status: Inactive
Brought to you by:
grro
|
From: Phyo A. <phy...@gm...> - 2009-11-01 00:31:16
|
When i run , and connect with web browser to port 8080 (i change ports to
8080 and 9090) it got error , as below..
on browser it gives InternalServerError too.
Am i doing something wrong?
Nov 1, 2009 6:55:54 AM org.xsocket.connection.Server$LifeCycleHandler
onConnected
INFO: server listening on 0.0.0.0:8080 (xLightweb 2.9/xSocket 2.7)
Nov 1, 2009 6:55:54 AM org.xsocket.connection.Server$LifeCycleHandler
onConnected
INFO: server listening on 0.0.0.0:9090 (xSocket 2.7)
Nov 1, 2009 6:56:16 AM
org.xlightweb.AbstractHttpConnection$RequestHandlerAdapter
performRequestHandler
WARNING: [78a41f9f124ad22431b5f0a2165S1] error occured by calling on request
org.xlightweb.AbstractHttpConnection$RequestHandlerAdapter$Mul...@1a....NumberFormatException:
For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at
SimpleDualPortServer$HttpRequestHandler.onRequest(SimpleDualPortServer.java:116)
at
org.xlightweb.AbstractHttpConnection$RequestHandlerAdapter.performRequestHandler(AbstractHttpConnection.java:2083)
at
org.xlightweb.AbstractHttpConnection$RequestHandlerAdapter.access$1400(AbstractHttpConnection.java:1993)
at
org.xlightweb.AbstractHttpConnection$RequestHandlerAdapter$MultithreadedRequestHandlerAdapter$1.run(AbstractHttpConnection.java:2271)
at
org.xsocket.SerializedTaskQueue.performPendingTasks(SerializedTaskQueue.java:161)
at
org.xsocket.SerializedTaskQueue.access$0(SerializedTaskQueue.java:139)
at
org.xsocket.SerializedTaskQueue$MultithreadedTaskProcessor.run(SerializedTaskQueue.java:189)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Nov 1, 2009 6:56:16 AM
org.xlightweb.AbstractHttpConnection$RequestHandlerAdapter
performRequestHandler
WARNING: [78a41f9f124ad22431b5f0a2165S2] error occured by calling on request
org.xlightweb.AbstractHttpConnection$RequestHandlerAdapter$Mul...@1a....NumberFormatException:
For input string: "favicon.ico"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at
SimpleDualPortServer$HttpRequestHandler.onRequest(SimpleDualPortServer.java:116)
at
org.xlightweb.AbstractHttpConnection$RequestHandlerAdapter.performRequestHandler(AbstractHttpConnection.java:2083)
at
org.xlightweb.AbstractHttpConnection$RequestHandlerAdapter.access$1400(AbstractHttpConnection.java:1993)
at
org.xlightweb.AbstractHttpConnection$RequestHandlerAdapter$MultithreadedRequestHandlerAdapter$1.run(AbstractHttpConnection.java:2271)
at
org.xsocket.SerializedTaskQueue.performPendingTasks(SerializedTaskQueue.java:161)
at
org.xsocket.SerializedTaskQueue.access$0(SerializedTaskQueue.java:139)
at
org.xsocket.SerializedTaskQueue$MultithreadedTaskProcessor.run(SerializedTaskQueue.java:189)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Nov 1, 2009 6:56:19 AM
org.xlightweb.AbstractHttpConnection$RequestHandlerAdapter
performRequestHandler
WARNING: [78a41f9f124ad22431b5f0a2165S3] error occured by calling on request
org.xlightweb.AbstractHttpConnection$RequestHandlerAdapter$Mul...@1a....NumberFormatException:
For input string: "favicon.ico"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at
SimpleDualPortServer$HttpRequestHandler.onRequest(SimpleDualPortServer.java:116)
at
org.xlightweb.AbstractHttpConnection$RequestHandlerAdapter.performRequestHandler(AbstractHttpConnection.java:2083)
at
org.xlightweb.AbstractHttpConnection$RequestHandlerAdapter.access$1400(AbstractHttpConnection.java:1993)
at
org.xlightweb.AbstractHttpConnection$RequestHandlerAdapter$MultithreadedRequestHandlerAdapter$1.run(AbstractHttpConnection.java:2271)
at
org.xsocket.SerializedTaskQueue.performPendingTasks(SerializedTaskQueue.java:161)
at
org.xsocket.SerializedTaskQueue.access$0(SerializedTaskQueue.java:139)
at
org.xsocket.SerializedTaskQueue$MultithreadedTaskProcessor.run(SerializedTaskQueue.java:189)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
On Sun, Nov 1, 2009 at 6:00 AM, Phyo Arkar <phy...@gm...> wrote:
> Dear Gregor
>
> Thanks a lot , I am check the code and i will test it out
>
> Regards,
>
> Phyo
>
>
> On Sat, Oct 31, 2009 at 8:10 PM, Gregor Roth <gre...@gm...> wrote:
>
>> Hi Phyo,
>>
>>
>> you can find a simple example for a dual port server here:
>> http://xlightweb.svn.sourceforge.net/viewvc/xlightweb/xlightweb/core/trunk/src/test/java/org/xlightweb/SimpleDualPortServer.java?view=markup
>>
>>
>> Gregor
>>
>>
>>
>> ----- Original Message -----
>>
>> From: Phyo Arkar
>>
>> Sent: 10/31/09 02:42 am
>>
>> To: xso...@li...
>>
>> Subject: [xSocket-develop] Trying to implement a Dual Port Server with
>> XSocket
>>
>>
>>
>> Hello XSocket Developers
>>
>> I am new to XSocket and trying to implement a Dual Port Server , One Port
>> accept incoming connection , read data and when other side connect , reply
>> to them
>>
>>
>> here is my example
>>
>>
>> RemoteWebServer<---Agent ---------------------------->XSocketServer:8090
>> <----------------> XSocketServer:9080 <<<<--------->Browser
>>
>>
>> I am wondering how to communicate data Internally between
>> XSocketServer:8090 <---------> XSocketServer:9080;
>>
>>
>> I am thinking to use shared synchronized object :
>>
>> Only Xsocket is used on server side relay is with socat (
>> dest-unreachable.com<http://mail-eu.gmx.com/fm07/cgi/derefer?TYPE=2&DEST=http%3A%2F%2Fdest-unreachable.com>
>> )
>>
>>
>>
>> Below is my code as far as it goes it dont work :D. will appreciate a lot
>> for anyyy help :
>>
>>
>> //------------ Begins
>> import java.io.IOException;
>> import java.nio.BufferUnderflowException;
>> import org.xsocket.MaxReadSizeExceededException;
>> import org.xsocket.connection.IDataHandler;
>> import org.xsocket.connection.IConnectHandler;
>>
>> import org.xsocket.connection.INonBlockingConnection;
>>
>> class Shared {
>>
>> static INonBlockingConnection camNBC = null;
>> static INonBlockingConnection brwNBC = null;
>> boolean value_cam = false;
>> boolean value_brw = false;
>>
>> synchronized INonBlockingConnection get_cam() {
>> if (value_cam == false)
>> try {
>> wait();
>> } catch (InterruptedException e) {
>> System.out.println("InterruptedException caught");
>> }
>> System.out.println("Gives Cam's: " + camNBC);
>> value_cam = false;
>> notify();
>> return camNBC;
>> }
>>
>> synchronized void put_cam(INonBlockingConnection nbc) {
>> if (value_cam == true)
>> try {
>> wait();
>> } catch (InterruptedException e) {
>> System.out.println("InterruptedException caught");
>> }
>> this.camNBC = nbc;
>> System.out.println("Set Camera: " + nbc);
>> value_cam = false;
>> notify();
>> }
>>
>> synchronized INonBlockingConnection get_brw() {
>> if (value_brw == false)
>> try {
>> wait();
>> } catch (InterruptedException e) {
>> System.out.println("InterruptedException caught");
>> }
>> System.out.println("Gives brw: " + brwNBC);
>> value_brw = false;
>> notify();
>> return brwNBC;
>> }
>>
>> synchronized void put_brw(INonBlockingConnection nbc) {
>> if (value_brw == true)
>> try {
>> wait();
>> } catch (InterruptedException e) {
>> System.out.println("InterruptedException caught");
>> }
>> this.brwNBC = nbc;
>> System.out.println("Set brw: " + nbc);
>> value_brw = false;
>> notify();
>> }
>>
>> }
>>
>> class BrowserHandler implements IDataHandler,IConnectHandler {
>>
>> Shared s;
>>
>> BrowserHandler(Shared s) {
>> this.s = s;
>> }
>> @Override <#124acef4188edf77_124aad346b05e7db_>
>> public boolean onConnect(INonBlockingConnection connection)
>> throws IOException, BufferUnderflowException,
>> MaxReadSizeExceededException {
>> // TODO Auto-generated method stub
>> s.put_brw(connection);
>> return false;
>> }
>> public boolean onData(INonBlockingConnection nbc) throws IOException,
>> BufferUnderflowException, MaxReadSizeExceededException {
>> String data = nbc.readStringByDelimiter("\n");
>> this.s.get_cam().write(data + " \r\n\r\n");
>> return true;
>>
>> }
>>
>>
>> }
>>
>> class CameraHandler implements IDataHandler,IConnectHandler {
>>
>> Shared s;
>>
>> public CameraHandler(Shared s) {
>> this.s = s;
>> }
>> @Override <#124acef4188edf77_124aad346b05e7db_>
>> public boolean onConnect(INonBlockingConnection connection)
>> throws IOException, BufferUnderflowException,
>> MaxReadSizeExceededException {
>> // TODO Auto-generated method stub
>> s.put_cam(connection);
>> return false;
>> }
>> public boolean onData(INonBlockingConnection nbc) throws IOException,
>> BufferUnderflowException, MaxReadSizeExceededException {
>>
>> String data = nbc.readStringByDelimiter("\n");
>> this.s.get_brw().write(data + " \r\n");
>> return true;
>> }
>>
>>
>> }
>>
>>
>> import java.io.IOException;
>> import org.xsocket.connection.IServer;
>> import org.xsocket.connection.Server;
>>
>>
>> public class main {
>>
>> public static void main(String args[]) {
>> try {
>> Shared s= new Shared();
>> IServer browse_side = new Server(8090, new BrowserHandler(s));
>> IServer cam_side = new Server(9080, new CameraHandler(s));
>>
>> // run it within the current thread.
>> //srv.run(); // the call will not return
>>
>> // ... or start it by using a dedicated thread
>>
>> browse_side.start();
>> cam_side.start();
>> } catch (IOException e) {
>> // TODO Auto-generated catch block
>> e.printStackTrace();
>> } // returns after the server has been started
>>
>>
>> }
>>
>> }
>>
>>
>>
>>
>>
>>
>>
>
|