autobahnandroid receive 502 error when connect to nginx server?

#1

a simple test code like this:

private void start() {

	//10.16.11.102:2040

	final String wsuri = "ws://fes.gw.com.cn/dataproxy";

	try {

		mConnection.connect(wsuri, new WebSocketConnectionHandler() {

			@Override

			public void onOpen() {

				Log.d(TAG, "Status: Connected to " + wsuri);

			}

			@Override

			public void onClose(int code, String reason) {

				Log.d(TAG, "Connection lost." + code);

			}

		});

	} catch (WebSocketException e) {

		Log.d(TAG, e.toString());

	}

}

``

and log is:

09-28 09:57:38.349: D/de.tavendo.autobahn.WebSocketConnection(1584): created

09-28 09:57:38.609: D/de.tavendo.autobahn.WebSocketReader(1584): created

09-28 09:57:38.669: D/de.tavendo.autobahn.WebSocketConnection(1584): WS reader created and started

09-28 09:57:38.669: D/de.tavendo.autobahn.WebSocketReader(1584): running

09-28 09:57:38.679: D/de.tavendo.autobahn.WebSocketWriter(1584): created

09-28 09:57:38.679: D/de.tavendo.autobahn.WebSocketConnection(1584): WS writer created and started

09-28 09:57:38.709: W/de.tavendo.autobahn.WebSocketReader(1584): Status: 502 (Bad Gateway)

09-28 09:57:38.709: D/de.tavendo.autobahn.WebSocketReader(1584): ended

09-28 09:57:38.779: D/de.tavendo.autobahn.WebSocketConnection(1584): fail connection [code = 6, reason = Server error 502 (Bad Gateway)

09-28 09:57:38.779: D/de.tavendo.autobahn.WebSocketReader(1584): quit

09-28 09:57:38.789: D/de.tavendo.autobahn.WebSocketWriter(1584): ended

09-28 09:57:38.789: D/de.tavendo.test1(1584): Connection lost.6

09-28 09:57:38.789: D/de.tavendo.autobahn.WebSocketConnection(1584): worker threads stopped

09-28 09:57:38.789: D/de.tavendo.autobahn.WebSocketConnection(1584): opening handshake received

``

how do i deal with my java code to make it work .

the server address is a remote url and i can’t do anything with it.

i can telnet it and send one key ,get the html:

HTTP/1.1 400 Bad Request

Server: nginx

Content-Type: text/html

Content-Length: 166

Connection: close

400 Bad Request

400 Bad Request


nginx

``

any one can help me.

···

Date: Sun, 28 Sep 2014 10:05:14 GMT

0 Likes

#2

forgive for my poor english ,but is it just my case or some one also meet it?

···

On Sunday, September 28, 2014 6:05:45 PM UTC+8, jichao liu wrote:

a simple test code like this:

private void start() {

  //[10.16.11.102:2040](http://10.16.11.102:2040)
  final String wsuri = "ws://[fes.gw.com.cn/dataproxy](http://fes.gw.com.cn/dataproxy)";
  try {
  	mConnection.connect(wsuri, new WebSocketConnectionHandler() {
  		@Override
  		public void onOpen() {
  			Log.d(TAG, "Status: Connected to " + wsuri);
  		}
  		@Override
  		public void onClose(int code, String reason) {
  			Log.d(TAG, "Connection lost." + code);
  		}
  	});
  } catch (WebSocketException e) {
  	Log.d(TAG, e.toString());
  }

}

``

and log is:

09-28 09:57:38.349: D/de.tavendo.autobahn.WebSocketConnection(1584): created

09-28 09:57:38.609: D/de.tavendo.autobahn.WebSocketReader(1584): created

09-28 09:57:38.669: D/de.tavendo.autobahn.WebSocketConnection(1584): WS reader created and started

09-28 09:57:38.669: D/de.tavendo.autobahn.WebSocketReader(1584): running

09-28 09:57:38.679: D/de.tavendo.autobahn.WebSocketWriter(1584): created

09-28 09:57:38.679: D/de.tavendo.autobahn.WebSocketConnection(1584): WS writer created and started

09-28 09:57:38.709: W/de.tavendo.autobahn.WebSocketReader(1584): Status: 502 (Bad Gateway)

09-28 09:57:38.709: D/de.tavendo.autobahn.WebSocketReader(1584): ended

09-28 09:57:38.779: D/de.tavendo.autobahn.WebSocketConnection(1584): fail connection [code = 6, reason = Server error 502 (Bad Gateway)

09-28 09:57:38.779: D/de.tavendo.autobahn.WebSocketReader(1584): quit

09-28 09:57:38.789: D/de.tavendo.autobahn.WebSocketWriter(1584): ended

09-28 09:57:38.789: D/de.tavendo.test1(1584): Connection lost.6

09-28 09:57:38.789: D/de.tavendo.autobahn.WebSocketConnection(1584): worker threads stopped

09-28 09:57:38.789: D/de.tavendo.autobahn.WebSocketConnection(1584): opening handshake received

``

how do i deal with my java code to make it work .

the server address is a remote url and i can’t do anything with it.

i can telnet it and send one key ,get the html:

HTTP/1.1 400 Bad Request

Server: nginx

Date: Sun, 28 Sep 2014 10:05:14 GMT

Content-Type: text/html

Content-Length: 166

Connection: close

400 Bad Request

400 Bad Request


nginx

``

any one can help me.

0 Likes