Code Monkey home page Code Monkey logo

as3websocket's Introduction

ActionScript 3 WebSocket Client

This is an AS3 implementation of a client library of the WebSocket protocol, as specified in the RFC6455 standard.

Explanation

THIS CLIENT WILL NOT WORK with draft-75 or draft-76/-00 servers that are deployed on the internet. It is only for the most recent RFC6455 standard. I will keep a version tracking each of the IETF drafts in its own branch, with master tracking the latest.

I intend to keep this library updated to the latest draft of the IETF WebSocket protocol when new versions are released. I built this library because I wanted to be able to make use of the latest draft of the protocol, but no browser implements it yet.

See the WebSocket Protocol Specification (RFC6455).

The AS3WebSocket directory contains a Flash Builder 4.6 Library Project that contains the WebSocket client library.

The testApp directory contains a Flash Builder 4.6 Air Project that uses the AS3WebSocket library and implements two of the test subprotocols from Andy Green's libwebsockets test server, the dumb-increment-protocol, and the lws-mirror-protocol. Click here for more detail about the libwebsockets test server.

License

This library is released under the Apache License, Version 2.0.

Download

  • The Adobe Air test application and the client library in SWC format are both available under the "Downloads" section above.

Features

  • Based on the RFC6455 standard WebSocket protocol
  • wss:// TLS support w/ hurlant as3crypto library
  • Can send and receive fragmented messages
  • Test Adobe Air app implements two of the subprotocols supported by Andy Green's libwebsockets-test-server:
    • dumb-increment-protocol (simple streaming incrementing numbers)
    • lws-mirror-protocol (shared drawing canvas)
    • Added fraggle-protocol to the list, but I'm having difficulty testing as there seems to be a problem with the libwebsockets-test-fraggle server (its own client complains of corrupt data intermittently when I run it on my machine)

Known Issues:

  • There is no user-provided extension API implemented
  • Only the libwebsocket-test-server subprotocols mentioned have been tested so far

Usage Example

var websocket:WebSocket = new WebSocket("wss://localhost:4321/foo?bing=baz", "*", "my-chat-protocol");
websocket.enableDeflateStream = true;
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");
}

private 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);
  }
}

as3websocket's People

Contributors

boris-mezhibovskiy-dd avatar clinch avatar creativedrewy avatar michielbrinkers avatar rejemy avatar theturtle32 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

as3websocket's Issues

Need help on connection with AutoBahn|Python

Dear sir,

I'm setup websocket server by using AutoBahn|Python on Amazon EC2 successfully connected to Javascript websocket.

However, I'm facing the problem on connecting to AS3WebSocket.

When I test the AS3 project as debug from FlashDevelop the WebSocketErrorEvent.CONNETION_FAIL Occur with following text

An HTTP response code other than 101 was received. Actual Response Code: 400 missing port in HTTP Host header '54.251.48.207' and server runs on non-standard port 10001 (wss=False)

When I run the project on web browser, WebsocketEvent.CLOSED occur without WebSocketErrorEvent.CONNECTION_FAIL
same as when I upload the project to Amazon EC2.

I'm not good in Networking background, so Please guide me through out the problem, Please.

Best Regards,
Chet Chetchaiyan

Connecting to latest socketIO server works, but I get disconnected immediately

I get a connected message when connecting to a socketIO server but then an immediate disconnect.
Any suggestions? This is my complete message

Connecting to 192.168.4.134 on port 3000
Socket Connected
GET / HTTP/1.1
Host: 192.168.4.134:3000
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: ZnyGKnse5Tsdr6znXQKGSA==
Origin: *
Sec-WebSocket-Version: 13
Sec-WebSocket-Protocol: lws-mirror-protocol

Socket Disconnected
Websocket closed.

Proxy?

Does this lib supports working under proxy?

Excessive TLS Record length

when I use the client to connect my websocket server , I got an error "TLSEngine shutdown triggered by Error: Excessive TLS Record length: 20527". then disconnected. I do not why.

Endianness of binary data

It seems that little-endian bytearrays are sent as big-endian. Is their a way for me to change that?
Thanks!

AIR SKD 3.4 complie error

Description: Implicit coercion of a value of type Boolean to an unrelated type Number.
Resource: Hex.as
Path: /AS3WebSocket/src/com/hurlant/util
Location: line 23
Type: Flex Problem

"if (hex.length&1==1)" May be as3 complier is more strictly in new version...

if ((hex.length&1)==1) is ok

Failed to connect Spring Boot 1.4.2 (Tomcat 8.5.6)

I'm trying connect to Spring Boot server (v1.4.2, Tomcat 8.5.6) valid CA signed certificate (SHA256withRSA, SHA1withRSA, 2048) and GOT ALERT! type=40, which looks like handshake issue. Any insight is appreciated.

[BUG?] Client not telling server to close, server not detecting "close" event.

Can you please guys give me a hand here?

ryo-ma/deno-websocket#16

My Deno WebSocketServer dispatches the "close" event with the Javascript built-in WebSocket when I close the HTML page.
But not with the AS3WebSocket lib when I close the NativeWindow. I even tried listening to the NativeProcessErrorEvent.ERROR event and force the websocket to close manually. The other events dispatch ok (new message and new client connection).

Thanks, cheers.

Request for Guidance on Upgrading to TLS 1.2

I am currently using the AS3WebSocket library in my application, which is configured to use TLS 1.0. I need to upgrade my application to use TLS 1.2. Recently, I encountered an issue where I could not connect to a new WebSocket server that requires TLS 1.2.

I would appreciate any guidance or instructions on how to achieve this upgrade.

Change Policy Server

Hi,

I used this for quite a while in my project. Works great!

However, we are now moving our server behind a CDN which allow only port 80 and 443.
This meaning that my local policy server that run under port 843 will not work any more, as the client will be block by the CDN.

So if client ask bar.foo.com --> resolve to the IP address of the CDN --> open sessions to port 80 or 443 --> goes to my origin server--> hit my server --> get to the web server --> hit back to the client.

Going into wireshark I can see that the client is trying to open port to 843 with the IP address of CDN server. This off course will not work as it get block by the CDN.
If I pass the CDN (by changing my hosts file) everything is working, as I have Policy Server running under the port 843.

Is there any way to configure my flash swf files to work with different policy server?
I tried the System.security.loadPolicyFile options but it is not seems to be working.

Any Idea?

Thank you.

Can't connect when embedded

I made a multiplayer game and used this and it works great but when I embed the swf to my site it will no longer connect. When I click connect nothing happens for 5 seconds then it runs the onWebSocketClosed event handler.

event.message also returned null

SHA1 error in AS3 Projects

http://stackoverflow.com/questions/20338864/as3websocket-library-sha1-error

I am trying to use https://github.com/Worlize/AS3WebSocket library. When I create Flex project everything ok, but when I create AS3 project it can't connect to a websocket server. Function SHA1.hashToBase64 (adobe.crypto library) inside Websocket class throws error:


 [SWF] TestWS.swf - 506,881 bytes after decompression

    typecheck com.adobe.crypto::SHA1$/hashToBase64()
    outer-scope = [global Object$]
    [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] *[A]] {} ()
    0:debugfile "/Users/turtle/work/as3corelib/project/src;com/adobe/crypto;SHA1.as"
    [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] *[A]] {} ()
    2:debugline 100
    [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] *[A]] {} ()
    4:getlocal0
    [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] *[A]] {} (com.adobe.crypto::SHA1$~[O])
  5:pushscope
                       [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] *[A]] {com.adobe.crypto::SHA1$~[O]} ()
  6:pushbyte 0
                       [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] *[A]] {com.adobe.crypto::SHA1$~[O]} (int[I])
  8:convert_u
                       [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] *[A]] {com.adobe.crypto::SHA1$~[O]} (uint[U])
  9:setlocal 7
                       [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  11:debug
                       [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  16:debug
                       [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  21:debug
                       [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  26:debug
                       [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  31:debug
                       [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  36:debug
                       [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  41:debugline 102
                       [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  43:getglobalscope
                       [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (global~[O])
  44:getslot 1
                       [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (com.adobe.crypto::SHA1$[O])
  46:getlocal1
                       [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (com.adobe.crypto::SHA1$[O] String[S])
  47:callproperty com.adobe.crypto:SHA1::createBlocksFromString 1
                       [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (Array[O])
  50:coerce Array
                       [com.adobe.crypto::SHA1$~[O] String[S] *[A] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (Array[O])
  52:setlocal2
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  53:debugline 103
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  55:findpropstrict com.adobe.crypto:SHA1::hashBlocks
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (com.adobe.crypto::SHA1$~[O])
  57:getlocal2
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (com.adobe.crypto::SHA1$~[O] Array[O])
  58:callproperty com.adobe.crypto:SHA1::hashBlocks 1
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (flash.utils::ByteArray[O])
  61:coerce flash.utils::ByteArray
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] *[A] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (flash.utils::ByteArray[O])
  63:setlocal3
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  64:pushstring ""
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (String~[S])
  66:debugline 109
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (String~[S])
  68:coerce_s
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] *[A] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (String~[S])
  69:setlocal 4
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  71:debugline 110
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  73:getlocal3
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (flash.utils::ByteArray[O])
  74:pushbyte 0
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (flash.utils::ByteArray[O] int[I])
  76:setproperty position
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  78:debugline 111
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  80:pushbyte 0
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (int[I])
  82:convert_i
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] *[A] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (int[I])
  83:setlocal 5
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] int[I] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  85:jump 129
------------------------------------
MERGE FIRST B129:      [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] int[I] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
------------------------------------
B129:                  [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] int[I] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  129:getlocal 5
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] int[I] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (int[I])
  131:getlocal3
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] int[I] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (int[I] flash.utils::ByteArray[O])
  132:getproperty length
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] int[I] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (int[I] uint[U])
  134:iflt 89
------------------------------------
MERGE FIRST B89:       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] int[I] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
------------------------------------
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] int[I] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  138:debugline 117
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] int[I] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} ()
  140:findpropstrict mx.utils::Base64Encoder
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] int[I] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (Object~[A])
  142:constructprop 14 0
                       [com.adobe.crypto::SHA1$~[O] String[S] Array[O] flash.utils::ByteArray[O] String~[S] int[I] *[A] uint[U]] {com.adobe.crypto::SHA1$~[O]} (*[A])
  145:coerce mx.utils::Base64Encoder
Connection Failure: There was an error while parsing the following HTTP Header line:
Sec-WebSocket-Accept: k9NwkeRGtpHKwr+kcSk29tHaAbs=
Disconnected

Type Coercion random Error

Sometime my as3 crashes throwing the following error:

TypeError: Error #1034: Type Coercion failed: cannot convert com.worlize.websocket::WebSocketErrorEvent@a47b661 to com.worlize.websocket.WebSocketEvent.

enableDeflateStream error

This line does not compile

websocket.enableDeflateStream = true;

1119: Access of possibly undefined property enableDeflateStream through a reference with static type com.worlize.websocket:WebSocket.

There is no such variable in the class, is that how it's meant to be?

Example for connecting to Socket.IO 0.9.x

Hello,

I'm unable to get a working example for interfacing with socket.io/engine.io.. Is there a working example somewhere? I've tried many things, but transport errors, missing protocols and destroyed upgrades are all I came up with...

Nicolas

Server

Any plans to make the server in as3?

Unable to connect

I'm trying to execute this part of the example:

websocket = new WebSocket("wss://echo.websocket.org", "*", "my-chat-protocol");
// websocket.enableDeflateStream = true;
websocket.addEventListener(WebSocketEvent.CLOSED, handleWebSocketClosed);
websocket.addEventListener(WebSocketEvent.OPEN, handleWebSocketOpen);
websocket.addEventListener(WebSocketEvent.MESSAGE, handleWebSocketMessage);
websocket.addEventListener(WebSocketErrorEvent.CONNECTION_FAIL, handleConnectionFail);
websocket.connect();

and I get an error:
Connection Failure: The server can not respond in any of our requested protocols
Disconnected

and in the trace output I have:
I DONT KNOW HOW TO HANDLE DER stuff of TYPE 12

Do you know what the problem might be?

Connect to Autobahn with Subscribe

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 '*'

AIR for mobile problem

Hi,

Im having a problem trying to stream microphone input using webSockets.
In my my micSampleDataHandler I'm converting the input and sending it through websocket.sendBytes(bytes) method.

While testing in emulator on desktop everything seems to work fine, but once i start testing on Android device websocket.sendBytes(bytes); seems to block the micSampleDataHandler. its looks like it stops the thread.
It does execute, but it takes much longer time. sending1 trace gets executed, but it takes a while to execute sending2 trace.

Do you maybe know what could be the cause of this? Shouldn't this be async?

This is my mic handler:

function micSampleDataHandler(event:SampleDataEvent):void
{

    var bytes:ByteArray = new ByteArray();
    while(event.data.bytesAvailable)
    {
        var sample:Number = event.data.readFloat();
        var integer:int;
        sample = sample * 32768 ;
        if( sample > 32767 ) sample = 32767;
        if( sample < -32768 ) sample = -32768;
        integer = int(sample);
        bytes.writeShort(integer);

    }

    trace("sending1");
    bytes.position = 0;
    websocket.sendBytes(bytes);
    trace("sending2");
}

not connecting

Its not connecting ...

Am connecting to a websocket

var net = require('net');
var http = require('http');

http.globalAgent.maxSockets = 1000;
var server_port = 4000;

function policy() {
var xml = '\n\n\n';
xml += '\n';
xml += '\n\0' ;
return xml;
}

console.log("server started");

//var WebSocketServer = require('/root/node_modules/ws').Server
var WebSocketServer = require('ws').Server
, wss = new WebSocketServer({ port: server_port });

wss.on('connection', function connection(ws)
{

       console.log("connection established");

	   ws.on('message', function incoming(message) 
	   {


	        console.log(message);
	        
	        if(message == '<policy-file-request/>\0')
	        {
	            var x = policy();
	            ws.send(x);
	            return;
	        }
			
	       
	    });

	    ws.on('close', function() {
	    
	    
	    });
					 
		ws.on('error', function() {
		      
		});

});

what could be the issue?

SHA1 cannot hash correctly

I using AS3WebSocket to connect socket.io server (ver 0.9+)
And I cannot connect my server, but when I change SHA1 library like #1 suggest, it work correctly.

I also try add as3crypto and use its' SHA1 library, and it also work correctly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.