kerryjiang / WebSocket4Net

A popular .NET WebSocket Client
Apache License 2.0
763 stars 273 forks source link

again "unknown server protocol version" #8

Closed symbiotic closed 11 years ago

symbiotic commented 11 years ago

hi, kerryjiang

i'm trying to connect to Mt Gox using their websocket API. but Websocket4Net gives the error "unknown server protocol version", when i do WebSocket.Open().

i saw that someone else ("shlomiw") also posted this problem. he mentioned that the origin should be "Origin: http://websocket.mtgox.com" and not "Origin: websocket.mtgox.com". the rfc 6455 that you told him you were going to look at confirms this too, in its examples.

can you look into this?

i'm connecting to Mt Gox with the following code:

WebSocket ws;

public Form1() // form constructor
{
    InitializeComponent();

    ws = new WebSocket("ws://websocket.mtgox.com/mtgox");
    ws.Opened += new EventHandler(ws_opened);
    ws.MessageReceived += new EventHandler<MessageReceivedEventArgs>(ws_message);
    ws.Error += new EventHandler<SuperSocket.ClientEngine.ErrorEventArgs>(ws_error);
    ws.Closed += new EventHandler(ws_closed);
}

private void btnTest_Click(object sender, EventArgs e)
{
    ws.Open();
}

private void ws_error(object sender, SuperSocket.ClientEngine.ErrorEventArgs e)
{
    SetMessage("error");
}
kerryjiang commented 11 years ago

Yes, you are correct.

But you can walk around it by passing the origin by yourself.

ws = new WebSocket("ws://websocket.mtgox.com/mtgox", origin = "http://websocket.mtgox.com");

From: symbiotic Sent: Saturday, July 27, 2013 1:46 AM To: kerryjiang/WebSocket4Net Subject: [WebSocket4Net] again "unknown server protocol version" (#8)

hi, kerryjiang

i'm trying to connect to Mt Gox using their websocket API. but Websocket4Net gives the error "unknown server protocol version", when i do WebSocket.Open().

i saw that someone else ("shlomiw") also posted this problem. he mentioned that the origin should be "Origin: http://websocket.mtgox.com" and not "Origin: websocket.mtgox.com". the rfc 6455 that you told him you were going to look at confirms this too, in its examples.

can you look into this?

i'm connecting to Mt Gox with the following code:

WebSocket ws;

public Form1() // form constructor { InitializeComponent();

ws = new WebSocket("ws://websocket.mtgox.com/mtgox");
ws.Opened += new EventHandler(ws_opened);
ws.MessageReceived += new EventHandler<MessageReceivedEventArgs>(ws_message);
ws.Error += new EventHandler<SuperSocket.ClientEngine.ErrorEventArgs>(ws_error);
ws.Closed += new EventHandler(ws_closed);

}

private void btnTest_Click(object sender, EventArgs e) { ws.Open(); }

private void ws_error(object sender, SuperSocket.ClientEngine.ErrorEventArgs e) { SetMessage("error"); } — Reply to this email directly or view it on GitHub.

symbiotic commented 11 years ago

great it seems to be working now. i wasn't sure about the other parameters. i filled them in because i'm still using .net 3.5:

ws = new WebSocket("ws://websocket.mtgox.com/mtgox", "", null, null, "UserAgent", "http://websocket.mtgox.com", WebSocketVersion.Rfc6455);

thanks