Dear Sir, We meet a connection problem when we use Mojo websocket as server and use AS3WebSocket as client, it's can not successly create a connetion between client and server.
This problem just happen when we update to Mojolicious 6, everything is ok in Mojolicious 5. Please give some guides. Thanks in advance. David ActionScript 3 WebSocket Client ( https://github.com/theturtle32/AS3WebSocket ) This is an AS3 implementation of a client library of the WebSocket protocol, as specified in the RFC6455 standard. server code: use Mojolicious::Lite; # WebSocket echo service websocket '/abc' => sub { my $c = shift; # Opened $c->app->log->debug('WebSocket opened'); # Increase inactivity timeout for connection a bit $c->inactivity_timeout(300); # Incoming message $c->on(message => sub { my ($c, $msg) = @_; $c->send("echo: $msg"); }); # Closed $c->on(finish => sub { my ($c, $code, $reason) = @_; $c->app->log->debug("WebSocket closed with status $code"); }); }; app->start; server debug: set MOJO_REACTOR=Mojo::Reactor::Poll morbo --listen "http://*:3333" websocket_server.pl Server available at http://127.0.0.1:3333 [Tue Mar 1 14:51:05 2016] [debug] GET "/abc" [Tue Mar 1 14:51:05 2016] [debug] Routing to a callback [Tue Mar 1 14:51:05 2016] [debug] WebSocket opened [Tue Mar 1 14:51:05 2016] [debug] 101 Switching Protocols (0.002318s, 431.406/s) [Tue Mar 1 14:51:05 2016] [debug] WebSocket closed with status 1006 client code: import com.adobe.serialization.json.JSON; import com.worlize.websocket.* var websocket:WebSocket = new WebSocket("ws://127.0.0.1:3333/abc", "*", "my-chat-protocol"); websocket.addEventListener(WebSocketEvent.CLOSED, handleWebSocketClosed); websocket.addEventListener(WebSocketEvent.OPEN, handleWebSocketOpen); websocket.addEventListener(WebSocketEvent.MESSAGE, handleWebSocketMessage); websocket.addEventListener(WebSocketErrorEvent.CONNECTION_FAIL, handleConnectionFail); websocket.connect(); function handleWebSocketOpen(event:WebSocketEvent):void { trace("Connected"); websocket.sendUTF("Hello World!\n"); var binaryData:ByteArray = new ByteArray(); binaryData.writeUTF("Hello as Binary Message!"); websocket.sendBytes(binaryData); } function handleWebSocketClosed(event:WebSocketEvent):void { trace("Disconnected"); } function handleConnectionFail(event:WebSocketErrorEvent):void { trace("Connection Failure: " + event.text); } function handleWebSocketMessage(event:WebSocketEvent):void { if (event.message.type === WebSocketMessage.TYPE_UTF8) { trace("Got message: " + event.message.utf8Data); } else if (event.message.type === WebSocketMessage.TYPE_BINARY) { trace("Got binary message of length " + event.message.binaryData.length); } } client debug: Disconnect -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.
