Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't connect. Connected Event never fires. #6

Closed
drazmo opened this issue Nov 29, 2011 · 6 comments
Closed

Can't connect. Connected Event never fires. #6

drazmo opened this issue Nov 29, 2011 · 6 comments

Comments

@drazmo
Copy link

drazmo commented Nov 29, 2011

I created new project and link to as3corelib.swc, FlashSocket.IO-0.7.x-Beta_1.swc, and WebSocket.swc.
I added sample code from README file. Tried using socket.io 8 and socket.io 7
I am using Flash CS5.5. I have noticed that if I run in debug mode it connects. Seems something is happening to fast and doesn't handshake properly.

-- I keep getting this message on the server:
info - socket.io started
debug - setting request GET /socket.io/1/flashsocket/1306369664936810977
debug - set heartbeat interval for client 1306369664936810977
debug - flashsocket writing 7:::1+0
warn - client not handshaken client should reconnect
info - transport end
debug - set close timeout for client 1306369664936810977
debug - cleared close timeout for client 1306369664936810977
debug - cleared heartbeat interval for client 1306369664936810977
debug - discarding transport

-- On the Client Side this is my output
webSocketLog: policy file: xmlsocket://dev.bigstar.tv:843
webSocketLog: connected
webSocketLog: request header:
GET / HTTP/1.1

Upgrade: WebSocket

Connection: Upgrade

Host: localhost:1935

Origin: flash.swf://undefined:undefined

Cookie:

Sec-WebSocket-Key1: A1 VO 96 &68 21X 3 5 4g=

Sec-WebSocket-Key2: # 16 m jd B 8 52 920- k

webSocketLog: sent key3: lY@Ù©H�?
webSocketLog: closed

-- server Code
var http = require('express'),
io = require('socket.io'),
sys = require('sys');

// socket.io
var socket = io.listen(1935, {transports:['websocket', 'flashsocket', 'xhr-polling']});

// Add a connect listener

socket.on('connection', function(client){

var interval = setInterval(function() {
  client.send('This is a message from the server!  ' + new Date().getTime());
},5000);
// Success!  Now listen to messages to be received
client.on('message',function(event){
  console.log('Received message from client!',event);
client.send('Echo: ' + event );
});
client.on('disconnect',function(){
  //clearInterval(interval);
  console.log('Client has disconnected');
});

});

@simb
Copy link
Owner

simb commented Nov 30, 2011

I have not tried to use this from Flash Pro. I'll see if I can put together a demo and see if it works.

@drazmo
Copy link
Author

drazmo commented Nov 30, 2011

Tried upgrading to latest websocket and got it working but still no success running from IDE. However, it works in debug mode. If I publish the swf works and .exe both connect successfully.

@drazmo
Copy link
Author

drazmo commented Dec 1, 2011

Found the problem...in FlashSocket.as constructor.

The urlLoader is getting request from cache! So it never initiates handshake...hence it works once in a while.

Changing link 57 to this fixes problem!

r.url = "http://" + domain + "/socket.io/1/?time=" + new Date().getTime();

@simb
Copy link
Owner

simb commented Dec 3, 2011

Nice find! Did you fork the project? if you want to submit a pull request I can merge it. If not no worries, I can just update the code.

@drazmo
Copy link
Author

drazmo commented Dec 5, 2011

No..I didn't fork...go ahead an update the code! Thanks for the help!

On Sat, Dec 3, 2011 at 1:51 AM, Simeon Bateman <
reply@reply.github.com

wrote:

Nice find! Did you fork the project? if you want to submit a pull request
I can merge it. If not no worries, I can just update the code.


Reply to this email directly or view it on GitHub:
#6 (comment)

@simb
Copy link
Owner

simb commented Dec 7, 2011

Fix applied to the source. Did you have to import Date?

@simb simb closed this as completed Dec 7, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants