I have a troll with support for Web Sockets and Microsoft Draft. I use the API provided by them for the server, as well as the Silverlight fix for browsers that do not support web sockets. The information I'm working with comes from http://channel9.msdn.com/Events/MIX/MIX11/HTM10 and http://html5labs.interoperabilitybridges.com/prototypes/websockets/websockets/info My code compiles in the order he begins to open the connection and then fails. Here is my server side server code (in C # console application)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.ServiceModel.WebSockets; namespace ChatBackend { class Program { static void Main(string[] args) { var host = new WebSocketsHost<MessageHandler>(); host.AddWebSocketsEndpoint("ws://localhost:4502/MessageHandler"); host.Open(); Console.ReadLine(); } } }
Here's the MessageHandler class:
class MessageHandler : WebSocketsService { public override void OnMessage(string value) { string returnMessage = "You just said '" + value + "'"; Console.WriteLine(value); SendMessage(returnMessage); } }
This backend part seems to be working fine. Here's the end of the client:
$(document).ready(function () { setTimeout(connect, 2050); }); function connect() { websocket = new WebSocketDraft("ws://localhost:4502/MessageHandler"); websocket.onopen = function() { websocket.send("test"); }; websocket.onclose = function () { alert("DIED"); }; websocket.onmessage = function(event) { sendMessage(new message(0, event.data, 0)); }; }
EDIT: I checked my firewall and allowed to use the port that I used. Now the connection just hangs - it does not close, it does not open. Any ideas?
EDIT 2: I did some more research, it turned out that I needed to remove clientaccesspolicy.xml. It also turns out that I never had it, but I returned to custom 302 forwarding instead of 404, which was not found. This is fixed, but no progress. He is just hanging.
EDIT 3: Tried to disable Antivirus and firewall, no change Thanks - let me know if I need more code or information here.
source share