AS3WebSocket icon indicating copy to clipboard operation
AS3WebSocket copied to clipboard

Connect to Autobahn with Subscribe

Open yozef opened this issue 7 years ago • 3 comments

I would like to connect to a websocket server (Autobahn), and then subscribe to a channel.

When I use this lib:

websocket = new WebSocket("wss://api.domain.com", "*", "wsservice");
				
websocket.addEventListener(WebSocketEvent.CLOSED, handleWebSocketClosed);
websocket.addEventListener(WebSocketEvent.OPEN, handleWebSocketOpen);
websocket.addEventListener(WebSocketEvent.MESSAGE, handleWebSocketMessage);
websocket.addEventListener(WebSocketErrorEvent.CONNECTION_FAIL, handleConnectionFail);
				
websocket.connect();

--- then ---
protected function handleWebSocketOpen(event:WebSocketEvent):void {
	websocket.sendUTF(JSON.stringify({
		"type": "subscribe",
		"channels": ['channel']
	}));
}

However when I try to connect, I get the following error:

I DONT KNOW HOW TO HANDLE DER stuff of TYPE 12
Connection Failure: An HTTP response code other than 101 was received.  Actual Response Code: 400 HTTP Origin header invalid: No host part in Origin '*'

yozef avatar Jan 03 '18 16:01 yozef

@yozef did you find a way around this?

sebastiantoro avatar Jan 22 '18 18:01 sebastiantoro

I haven't.

yozef avatar Jan 22 '18 20:01 yozef

I solved a very similar issue changing new WebSocket("wss://api.domain.com", "*", "wsservice") for new WebSocket("wss://api.domain.com", "", "wsservice") ("*" to "")

sebastiantoro avatar Jan 22 '18 20:01 sebastiantoro