Git Product home page Git Product logo

alchemy-websockets's People

Contributors

ajacksified avatar chrelad avatar doriangray avatar jhaygood86 avatar krizzzn avatar lloydpickering avatar madlord avatar ssdvn 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  avatar  avatar  avatar

alchemy-websockets's Issues

NuGet package

It would be nice if there was a NuGet package for Alchemy-Websockets.

Issues with larger messages

Hey guys. I wanted to say that I think this project is pretty awesome. I was doing some experimenting with WebSockets and was very disappointed with the HTML5Labs' .net server implementation because of it's blatant lack of support for all previous versions of the protocol before the most recent hybi10 spec. Your implementation is pretty well-rounded, though and I've been pretty happy with what I've seen. :) That being said, I ran into an issue when I was playing around with the example and I was wondering if you could shed some light on it. I'm running the server locally and it seems to work fine when I navigate to the example webpage. I can type short messages and see them just fine in the chat window across multiple instances of the client. However, when I type somewhat large messages in the chat window (I've observed the issue beginning at about 84 characters), the server fails to broadcast the message to the other clients (Note that I debugged the program and I saw that the server is actually receiving the message and does get to the u.Context.Send(message); line but the clients just don't seem to receive the message sent). Is this a configuration error on my part or am I missing something? I'm using dev channel Chrome (v15.0.874.5), which implements the hybi10 spec of WebSockets, right now to test it. Thanks!

hybi00 DataFrame: Payload loses data in Append()

I've got a simple test server running with Alchemy. I can pass data back and forth with Chrome (hybi10) but not with Safari (latest version, w/ hybi00).

Safari connects fine, but when I send data over the socket (Safari to server), it's not in the UserContext by the time it gets to my OnReceive handler.

In the debugger, I've tracked it enough to see the the data come in and get added to the Payload in hybi00.DataFrame.Append, but it "disappears" (Payload count goes from 1 to 0) when I step out of the "if (data.Length > 0)" block...usually. I won't go into all the hoops I've jumped trying to diagnose it; suffice it to say it's one of those "impossible" behaviors that usually ends up being some absolutely obvious oversight (on my part), but I'm stumped.

Bug: DataFrame.Wrap() modifies provided byte array

The WebSocketHandler.Send() method passes its given parameter Data byte array to the DataFrame.Wrap() method which in turn calls its private method Mask() which in turn manipulates the byte array.

As a result, since arrays types are reference types ( see http://msdn.microsoft.com/en-us/library/9b9dty7d.aspx ), the Send() method modifies the original provided byte array. (Note: since arrays are reference types already, the ref keyword in the Mask() method parameter list is not necessary, if you want to modify the array content only!)

Example for better understanding:

          server.DefaultOnReceive = (ctx) =>
          {
            byte[] data = ctx.DataFrame.ToBytes();
            foreach (UserContext context in clients)
              if (context.ClientAddress != ctx.ClientAddress)
                context.Send(data);
          };

In the foreach loop the first client will receive a correct message from the server. The second client will receive damaged data, since the previous call to the Send() method modified the data-byte array.

Issue with Chrome ver 19.0.1084.52 m

I've been using the WebSockets library on my test server since about a month. A few days ago it stopped working. On investigating , I found the following error message: "A server must not mask any frames that it sends to the client."
I think this happened after the Google Chrome browser was updated to version 19.0.1084.52 m.

Ability for server to close a connection from the context?

Is there a way to close the connection from the server end?

For example, when a client connects:

void OnConnected(UserContext context) { ... }

Could we do something like context.???.Disconnect(); to close the socket? It looks like the TcpClient is tucked away pretty well so I'm not sure how to close it from the server side.

Maybe it's there and I don't see it, maybe I don't understand how this should work, or maybe this is a feature request?

hybi-17 (RFC 6455) support

Hi. Maybe I'm missing something, but I don't see hybi-17 (same as RFC 6455?) support in the latest code, though the Alchemy home page says it's supported.

For instance, there's no hybi17 Protocol (in Header.cs). And when I use Chrome (ver. 17, using RFC 6455 since ver. 16), the UserContext protocol is set to hybi10 (and the socket connection isn't always made).

Many thanks, Dave

hybi-17 support

Chrome 6 uses hybi-17, which has some breaking changes. Draft 17 is also staged for final publication as the standard at http://www.rfc-editor.org/authors/rfc6455.txt.

Targetted support should be hybi-00, 10, and 17 for maximum browser support until 00 and 10 can be safely dropped.

JSON messages truncated

I noticed an error when sending long JSON formatted messages between an Alchemy websocket server and Alchemy websocket client.
The string is not entirely transmitted and data is therefore corrupted.
The communication works fine only if client and server and on the same host.

Communication between a websocket-compatible browser and Alchemy's websocket server works fine, which most likely indicates an issue with the client implementation.

Server drops inbound messages and receives corrupted input.

I am observing an issue with the following application:

http://dl.dropbox.com/u/40949268/Bugs/Alchemy/Program.cs

This server program accepts all connections and prints all messages it receives to console.

I am using the following html application to test:

http://dl.dropbox.com/u/40949268/Bugs/Alchemy/client.html (links to http://dl.dropbox.com/u/40949268/Bugs/Alchemy/sendtest.js )

The application connects to localhost, and when the user presses a button, it sends the messages "Test=0", "Test=1", ... , "Test=999" to the server in one for loop.

The result I am observing with test is that the server application does not receive all the messages, and in some cases, it receives complete garbage and malformed input.

The TCP data stream was investigated with Wireshark, and it seems to be intact and contains all the messages.

This problem seems to be exaggerated/caused by a race condition inside Alchemy, since the time that it takes for the server to process a message OnServerReceive affects on how much data is corrupted and/or dropped.

To demonstrate the problem, the Program.cs server program was run with both Thread.Sleep enabled and disabled (the commented line 46 in the file). For the client, the browsers Firefox 12, Opera 11.64 and Chrome 19.0.1084.52 m were tested.

Here are the resulting print logs from each test run:

Firefox + Sleep enabled:
Client: http://dl.dropbox.com/u/40949268/Bugs/Alchemy/FirefoxClient_Sleep.txt
The result is as expected.
Server: http://dl.dropbox.com/u/40949268/Bugs/Alchemy/FirefoxServer_Sleep.txt
Broken, server has dropped several inbound messages.

Opera + Sleep enabled:
Client: http://dl.dropbox.com/u/40949268/Bugs/Alchemy/OperaClient_Sleep.txt
The result is as expected.
Server: http://dl.dropbox.com/u/40949268/Bugs/Alchemy/OperaServer_Sleep.txt
Broken, the server has dropped several inbound messages, and calls the message handler with null data frames.

Chrome + Sleep enabled:
Client: http://dl.dropbox.com/u/40949268/Bugs/Alchemy/ChromeClient_Sleep.txt
Unexpected: The client receives a message "A server must not mask any frames that it sends to the client. :1"
This seems to relate to bug #21.
Server: http://dl.dropbox.com/u/40949268/Bugs/Alchemy/ChromeServer_Sleep.txt
Broken, the server has dropped several messages, and calls the message handler with corrupted data frames.

The Thread.Sleep(10) was present in the above tests to measure the effects of timing for this problem. The results:

Firefox + No Sleep:
Client: http://dl.dropbox.com/u/40949268/Bugs/Alchemy/FirefoxClient_NoSleep.txt
The result is as expected.
Server: http://dl.dropbox.com/u/40949268/Bugs/Alchemy/FirefoxServer_NoSleep.txt
At first glance, the result is seemingly good, but the server has still dropped some messages (in particular e.g. "Test=2")

Opera + No sleep:
Client: http://dl.dropbox.com/u/40949268/Bugs/Alchemy/OperaClient_NoSleep.txt
The result is as expected.
Server: http://dl.dropbox.com/u/40949268/Bugs/Alchemy/OperaServer_NoSleep.txt
Broken, the server has dropped some messages, and calls the message handler with null data frames.

Chrome + No Sleep:
Client: http://dl.dropbox.com/u/40949268/Bugs/Alchemy/ChromeClient_NoSleep.txt
The result is as expected. Note that the same client error that was present when Thread.Sleep was used on the server does not occur here.
Server: http://dl.dropbox.com/u/40949268/Bugs/Alchemy/ChromeServer_NoSleep.txt
Broken, the server has dropped some messages.

Also it was observed that if one sleeps in the javascript client code in between data sends, that alleviates the number of dropped messages, so this issue may be related to how multiple frames are decoded and assembled in the TCP stream when the amount of available bytes to read in the socket varies on the server.

Sending Multiple byte[]

When sending consecutively I only get the first sent array.

clientSocket.Send(byteArrayX);
clientSocket.Send(byteArrayY);

I only recieve byteArrayX... I'm not sure if I'm doing something wrong on my end or its the method.

Possible version detection problem

I'm testing Alchemy Websockets in Chrome 17.0.963.56 on Mac. Currently I have problems with client to server message sending. My client sends message like

{"Type":"Auth","Msg":{"SessionId":"test1"}}

But server OnReceive handler gets

ABw8UmFuZG9tQnl0ZXM%2ba19fQmFja2luZ0ZpZWxkHDxDcmVhdGVkRGF0ZT5rX19

The other strange thing is that HTTP Upgrade request have headers

Sec-WebSocket-Key:DzPxIMY4zgU+jUcfVIO+ZQ==
Sec-WebSocket-Version:13
Upgrade:websocket

But server thinks that protocol is Hybi10. Is this correct?

PS. Test project source is https://github.com/akurdyukov/NancySelfHost

Flashsocket no longer receiving Connected()

Hi there,

after upgrading to the latest version from git, browsers using the flashsocket fallback will not trigger the JavaScript Connected() callback anymore.

They do establish a connection (I see that on my server) and they also get the Disconnected() when the server goes down, but they never get to the Connected() ...

Except for upgrading the server, I did not change anything client side.

Is anyone else having the same issue / can verify this?

EDIT:
I was able to verify the issue myself. After downgrading to version https://github.com/Olivine-Labs/Alchemy-Websockets/tree/1d73aeaee855a63fb9a94640e67f739705ca10c4 the problem is gone and the flashsocket fires the Connected() ...

Alchemy performance is horrible with large number of clients

Alchemy performance is horrible with large number of clients ( > 1000).

I rewrote large portions of the concurrency control for our local build which was able to handle >10,000 concurrent users on a single Amazon small instance.

Summary of changes:

  1. Switch to SocketAsyncEventArgs (2 per context -- 1 for sending, 1 for receiving) and SendAsync/ReceiveAsync versus using Begin/End
  2. Use static threads for actual receiving and sending of messages
  3. Don't "block" on threadpool threads -- reduces threads from 1 per connection to a few for all several thousand (i.e., return on OnRunClient immediately and let static worker threads do the work)

You can see our diff at: https://gist.github.com/4199234

hybi10 support?

Can't seem to get it working with the latest chrome dev (14.0.835.18). I guess it's because of the switch to the hybi10 spec.

I tried to deploy on Mono(Linux),but there is error

I deloy a websocket server based on Alchemy Libs, and it is running well at Windows System.
But When I deploy to CentOS, the Server CAN accept the client's connection, BUT the client will be DISCONNECTED for a while.
Is the data format different at Mono? Or someone else meet with the same problem?

Alchemy WebSocketClient throws an exception if the server refuses a connection

Alchemy WebSocketClient throws an exception if the server refuses a connection

        try
        {
            _client.EndConnect(result);
        }
        catch (Exception)
        {
            Disconnect();
        }

If the caught exception is due to the initial connection failing, then _context is null in Disconnect(). There are several cascading failures past that if you fix that.

Masked Response Error - Using Web-Socket-Js

I'm using Alchemy with Web-Socket-Js (to support other browsers).
The first days everything worked well, but now, for browsers using websockets through flash i get this error in console:

[WebSocket] Fail connection by client: code=1002 reason=Frame from server must not be masked.

followed by the closing of the connection.

Investigating into Web-Socket-Js i find this issue. They updated the project in order to close connection, with masked response.

Alchemy recognizes the protocol as 'hybi10'...

It is right? Someone has an idea wheres the problem and how to solve it?

Thanks, i'll investigate the problem too.

UserContext class should expose _context as protected instead of private

Hello, i wanted to disconnect an user which is connect to my server but there no method available for this operation. The fix would be the change the _context protection level from the UserContext class to protected so we can inherit from the UserContext class and add our own method which could also enable us for more control or just implement a disconnect method. I want your opinion on that. Is there a reason why the _context is private ?

NullReference Exception when server is not running

I'm trying to handle the case when the server is not available. Unfortunately Alchemy Client seems to crash with no possibility to catch the connection error:

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at Alchemy.WebSocketClient.Disconnect()
   at Alchemy.WebSocketClient.OnRunClient(IAsyncResult result)
   at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at System.Net.ContextAwareResult.CompleteCallback(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.ContextAwareResult.Complete(IntPtr userToken)
   at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
   at System.Net.Sockets.Socket.MultipleAddressConnectCallback(IAsyncResult result)
   at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at System.Net.ContextAwareResult.Complete(IntPtr userToken)
   at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
   at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

All this in a spearate Thread after running:

aClient.Connect();

Is there any other way to catch this error so I could handle the case when the server is not available?

Incorrect byte[] handling

I noticed 3 issues when developing a test server application. I also found the bugs within and I am sharing it with you. If you find it relevent please update your code. And thanks for providing this wonderful library.

When the websocket client send a large byte[], say > 1024 bytes, data to the server, there is some data corruption happening. What I send is not what I receive.

Cause: Hybi10 DataFrame::Append method incorrectly handles incoming data, There are 2 issues within it.
Solution:

Issue 1:
Original Code:

                   data = new byte[ Math.Min(Convert.ToInt32(Math.Min(_header.PayloadSizeRemaining, int.MaxValue)),
                                 someBytes.Length)];

Ideally, we need to subtract headerBytes.Length from someBytes.Length, since we already removed the header part. If this is not done, then there would be a 4 byte hole within our first segment.

Fix:

                   data = new byte[ Math.Min(Convert.ToInt32(Math.Min(_header.PayloadSizeRemaining, int.MaxValue)),
                                 someBytes.Length - headerBytes.Length)];

Issue 2:
Original Code:

             else
            {
                dataLength = Math.Min(Convert.ToUInt64(data.Length), _header.PayloadSizeRemaining);
                if (dataLength < Convert.ToUInt64(data.Length))
                {
                    data = new byte[dataLength];
                    Array.Copy(someBytes, 0, data, 0, Convert.ToInt32(dataLength));
                }
            }

When the dataLength is equal to 512 bytes, the current code would not copy the incoming byte[] into the new buffer, instead, this would set the reference of original byte[] as data. This is incorrect, because when the next packet arrives via socket, this data gets modified, and we would end up corrupting the earlier data.

Fix:

            else
            {
                 //Always copy
                dataLength = Math.Min(Convert.ToUInt64(data.Length), _header.PayloadSizeRemaining);
                data = new byte[dataLength];
                Array.Copy(someBytes, 0, data, 0, Convert.ToInt32(dataLength));
            }

Issue 3:
When the server send a byte[] back to the client the websocket frame header always sets the Opcode as 1 (which represents Text). One would expect this to be set as Binary( Opcode 2) since we are sending byte[]

Cause: FrameHeader::ToBytes().

Original Code:

data[0] = 0x81; //This is harcoded as Text.

Solution:
If the data is sent as byte[], then we would expect data[0] = 0x82. So there needs to be some distinction between text and binary data.

Synchronic Send

A nice feature to have is the ability to have a synchronic Send method. I understand that the basics of sockets are async communications, but for a specific application I'm working on I found that a sync send method would simplify my life a lot :) I need to send a packet and be sure that the packet is sent before continuing doing things (like sending more -async- packets).

Received illegal masked frame, using AS3WebSocket library

hi,
I am now using AS3Websocket ( https://github.com/Worlize/AS3WebSocket ) to write an AIR web-socket client application, and using application written in C# with Alchemy as server.

when I connect client to websocket.org echo test server( http://www.websocket.org/echo.html ), I can send and receive data perfectly;
when client connect to my server, client sends and server receives; but when server sends and client receives, the client shows error code 1002, said received illegal masked frame from server.

Having a quick look about the error code according to the specification of RFC6455 (http://tools.ietf.org/html/rfc6455#section-5.1)
"A server MUST NOT mask any frames that it sends to the client.".
Hence, I guess there is something wrong about the protocol between the client and server.

I would kindly ask for your support on this issue, any help would be great :)

Large Dataframes

Large dataframes are received over multiple threads and server goes WAT??

Alchemy can't bind socket without root access

I'm running ArchLinux and Mono 2.10.8. If I create a WebSocketServer object and call Start() on it, my program will throw an exception unless the program as run as root.

I'm fairly confident that binding to a socket does not require root access. If I write some socket code myself and bind to a socket, it works just fine as a regular user.

Here is the exception text it throws:

Unhandled Exception: System.Net.Sockets.SocketException: Access denied
at System.Net.Sockets.Socket.Bind (System.Net.EndPoint local_end) [0x00000] in :0
at System.Net.Sockets.TcpListener.Start (Int32 backlog) [0x00000] in :0
at System.Net.Sockets.TcpListener.Start () [0x00000] in :0
at Alchemy.TcpServer.Listen (System.Object state) [0x00000] in :0

hybi 10 does not connect with same ip

I have run into a strange issue. If i am running the client and server on the same IP then it doesn't connects with Hybi 10 protocol. Say for example my client is running on "http://192.168.0.123/test.html" and server is also running on the same IP i.e. 192.168.0.123:8181 then it wont connect with Hybi 10 protocol. Make sure to call the server like "ws://192.168.0.123:8181/websockets".

Has anyone else faced this issue? i have tested this on latest versions of chrome and safari. Both have same issue. Whereas older versions of these browsers work fine, because they are implementing 76 version of the protocol.

Safari 6 Mac/iOS Headers

Hi,

Can you confirm that Alchemy is not handling the Safari 6 headers correctly. Safari does not send the version or other headers for that matter, just the upgrade request and hence it gets recognized as hybi00 and after that it all goes wrong.

Any help?

Forgotten Console.Write in DataFrame?

In Alchemy.Server.Handlers.WebSocket.hybi10.DataFrame there is the following line inside the Wrap() method:

Console.WriteLine(Encoding.UTF8.GetString(WrappedBytes));

It seems that someone forgot to remove their debugging code? ;-)

PS:
Reporting this, since that line spams my Console Window which slows down and sometimes even crashes my console window server application...

Support for wss://

Currently, there is no support for secured data connection. It would be very useful to add this feature for data transfers which must happen in a secure connection.

Virus warning for http://olivinelabs.com/

This is the warning my eset anti virus shows in Firefox when I go to your site:

ESET NOD32 Antivirus
Access denied

Details:
Web page: http://olivinelabs.com
Comment: Access to the web page was blocked by ESET NOD32 Antivirus. The web page is on the list of websites with potentially dangerous content.

Not sure if this is valid, but you might want to do something about it if this is valid.

New DLL ?

Hi

Background
We've been developing an offline application that will (when released) be running on mobile devices. We chose alchemy for our websocket setup. Now using it for 6 months... Our use involves data syncronization using JSON between an SQL Server DB and SQLite DB on the mobile devices.

At the moment we have trouble with Chrome & Chrome canary - we can connect to the server, but long messages are not receiving or sending.
... but Safari is working fine. 100%
We don't believe this is an Alchemy problem, but in case it is, can you please compile a new dll with the latest round of bug fixes and make it available.

Thanks
Roger

UserSocket Connect not behaving like expected

The server side UserContext Connect delegate does not behave like one might expect...

What I expect:
The Connect delegate is called once the connection establishing and handshake are complete, so I can greet every newly connected user with a "welcome message" inside the Connect delegate.

What happens:
The Connect delegate is called before the handshake which causes errors / disconnects, if one messages the client inside the Connect delegate.

Workaround:
Right now you have to poll the UserContext.IsSetup property in order to find out when a client is ready for receiving custom messages.

Solution:

  1. Call the Connect delegate after the handshake.
    OR
  2. Split the delegate into 2 separate delegates: Connecting (is called before handshake) and Connected (is called after handshake).

OnReceive after OnDisconnect

I'm not sure if I'm using this incorrectly, but I'm a bit confused about the timeout and OnDisconnect.

I've got a client/server working pretty well. But, after the timeout (I used the example of 5 minutes) it fires OnDisconnect, but it doesn't close the connection. Then, if the client sends a message, OnReceive fires.

The reason this is a problem in my case is because I remove the "client" from known clients assuming they'll reconnect later. However, then on OnReceive I can't find the context because I removed it from my known client list.

Am I doing something wrong, or am I supposed to forcefully close the connection some how on the timeout's OnDisconnect call?

Or, is this a bug of some sort, leaving the open connection? Could it be that I have a reference somewhere which isn't GC'd and the socket only closes on dispose? Although I do store a reference in my own "Connection" class, on disconnect I set this.Context = null;

Thanks for any thoughts.

(Is there a way to contact you directly?)

Converter error

Hi,
Sorry about my english!

In file FrameHeader.cs I have found a little conversion error. On line 84:

data = BitConverter.GetBytes(Convert.ToInt16(PayloadSize));

I have got exception on message length of 65500 bytes so I have changet that line to:

data = BitConverter.GetBytes(Convert.ToUInt16(PayloadSize));

By the moment works fine.

Byeer! :)

Suggestion: Add ToByteArray method on the DataFrame

Hi,
I just added a ToByteArray method to the DataFrame class. Since I can send either a string or a byte[], why not can I get a byte[] from my context?

Since I don't use Git, I'm pasting here the code. Hope it could be helpful to others.

public byte[] ToByteArray() {
    List<ArraySegment<byte>> arrays = AsRaw();
    byte[] rv = new byte[arrays.Sum(array => array.Array.Length)];
    int offset = 0;
    foreach (byte[] current in arrays.Select(array => array.Array)) {
        Buffer.BlockCopy(current, 0, rv, offset, current.Length);
        offset += current.Length;
    }
    return rv;
}

Use CultureInfo.InvariantCulture in some ToString methods

Hi,
On some classes, you might want to add CultureInfo.InvariantCulture to the ToString method (specifically to the context.Server.Port.ToString on the two Authentication classes).

It is good practice as you don't know the locale that might be set on the server, and while a port is an integer (so, you don't have issues with dot/comma swapped out), by experience I can tell you that on some middle-east locations, you might end up comparing a port number with Arabic numbers.

SocketException: Access denied

Trying to create a websocket server on an unprivileged port with

var socketServer = new Alchemy.WebSocketServer(9970, IPAddress.Any)

I get this exception (on a different thread):

System.Net.Sockets.SocketException: Access denied
at System.Net.Sockets.Socket.Bind (System.Net.EndPoint local_end) [0x00051] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System/System.Net.Sockets/Socket.cs:1104
at System.Net.Sockets.TcpListener.Start (Int32 backlog) [0x00022] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System/System.Net.Sockets/TcpListener.cs:268
at System.Net.Sockets.TcpListener.Start () [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System/System.Net.Sockets/TcpListener.cs:243
at Alchemy.TcpServer.Listen (System.Object state) [0x00000] in :0

Use async socket?

Why Alchemy don't use async socket directly instead of TcpListener?

And why make an infinite loop on RunClient? It's not better use a Timer to check if the websocket is alive?

problems sending byte[]

Hi,

Firstly great library, it's far simpler to get going than some of the alternatives, so major kudos for that.

I am having a little problem sending byte[] from s->c though.

When using UserContext.Send(Byte[]) I receive an error client side (with 'Could not decode a text frame as UTF-8'. shown in Chrome's console).

If I send it through as System.Convert.ToBase64String(Byte[]) it comes through just fine.

My clientside is setup like:

var connection = new WebSocket("ws://hostname:port/");
connection.binaryType = "arraybuffer";
connection.onmessage = function (e) {
    if (event.data instanceof ArrayBuffer)
    {
    } else {
    }
}

Where am I going wrong?

I'd really rather not have to base64 encode/decode strings when I have everything setup for dealing with ArrayBuffer and TypedArrays (WebGL).

onmessage event handler isn't fired in Safari

Running Safari 5.1.2 and Alchemy commit 9174017 (12/21/11).

With a very simple websocket server, call UserContext.Send(string) with a live connection. The browser-side function assigned to WebSocket.onmessage gets triggered with the correct data in Chrome but does not get triggered at all in Safari.

Also tried it using the Alchemy javascript client library, same deal: Alchemy.MessageReceived doesn't get called in Safari.

Running the server in the debugger, I can't see the problem. BeginSend is called on an open TcpClient connection socket in Handler.Send and there's no error. Maybe the data format is incorrect for hybi00, as in the recent OnReceive problem?

Thanks, Dave

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.