Open Luke47 opened 8 years ago
I think i found the issue: Our websocket server only accepts UTF8 strings, but MiniWamp uses binary formatted messages. This leads to immediate closing of the connection after sending the first message.
Hmmm...The default is to always send text I believe. Both the MessageWebSocket and the WebSocket classes are sending with UTF-8 encoding.
Off the top of my head I am not sure where your issue would be. But I do see two issues that need to be addressed via MiniWamp:
Call
s as well.I'll try and roll out an update this week.
Thanks for your support. Debugging log would be great :)
I just tried to build some some simple websocket stuff by myself and it works. Maybe I'm missing some configuration with MiniWamp. But the debug log would help discovering that.
Out of curiousity, what is your current setup? Are you using the .Net 4.5 version or the PCL? And what is your server?
My setup is:
wss://XYZ.com/ws/?auth_token=XYZ
( I get [0,"0LXM2d6dZdJC2VTv",1,"gevent-websocket\/0.9.5"]
as a response, so connection seems to work fine)http://domain/users/get_profile
-> now I do not get anything back.Do you need to know anything else?
If I try to do it manually, it works (maybe I'm overseeing something?). That are the snippets I use:
Connecting / Sending
Uri echoService = new Uri("wss://XYZ.com/ws?auth_token=XYZ", UriKind.Absolute);
MessageWebSocket messageWebSocket = new MessageWebSocket();
messageWebSocket.Control.MessageType = SocketMessageType.Utf8;
messageWebSocket.MessageReceived += MessageWebSocket_MessageReceived;
messageWebSocket.Closed += MessageWebSocket_Closed;
await messageWebSocket.ConnectAsync(echoService);
var writer = new DataWriter(this.messageWebSocket.OutputStream);
object[] messageToSent = new object[3];
messageToSent[0] = 2;
messageToSent[1] = "d7ayjg9vutw1ny8jtyd7h9f6r";
messageToSent[2] = "http://domain/ping";
writer.WriteString(JsonConvert.SerializeObject(messageToSent));
await writer.StoreAsync();
Receiving
private void MessageWebSocket_MessageReceived(MessageWebSocket sender, MessageWebSocketMessageReceivedEventArgs args)
{
using (var reader = args.GetDataReader())
{
reader.UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.Utf8;
var text = reader.ReadString(reader.UnconsumedBufferLength);
Debug.WriteLine("Response is:" + text);
}
}
I've just downloaded your source code and did some tests. I don't know if this was changed recently, but for me, the default websocket messagetype was binary
. After adding
this._socket.Control.MessageType = SocketMessageType.Utf8;
to
MessageWebSocketTransport
it works flawlessly.
Thank you for your help so far! :)
Hmm...I guess I need to have some more integration tests. Glad it is working though! I'll add your change into my fix.
Thanks for your work! :) I was able to fix all my remaining issues (https://github.com/paulpdaniels/MiniWamp/issues/8 & some issues related to our server)
Keep up the good work!
Hey!
Thanks for this cool library.
I have a question regarding debugging it. Connection to the websocket works fine, I got a session id and it seems connected. But it seems that I do not get any response from the websocket.
Meaning, i receive no event notifications after subscribing and when calling for example
var sum = await session.Call<int>("rpc#add", 3, 4); //sum = 7
it is "awaiting" forever.Do you have an idea how to debug this? Is there some debug log, which I can enable, which prints out all the communication which happens between the websocket and MiniWamp?
Thank you :)