How to ping a WebSocket server using a WampSharp Client?

1.7k views Asked by At

I have created a WebSocket server in python using the Wamp WS. I am connecting a DotNet application containing the WampSharp client with the above mentioned WebSocket server using the following code:

DefaultWampChannelFactory channelFactory = new DefaultWampChannelFactory();
channel = channelFactory.CreateChannel(serverAddress);
channel.Open();

Now I need to ping my server from the client. When I had a look at the Wamp WS client created in Python it consisted of the sendPing(self,payload) function which would ping the server as follows:

WampClientProtocol.sendPing(self, payload)

and at server side there is a onPing function which handles the ping sent as follows:

def onPing(self, payload): print "Recieved ping message successfully"

Thus, I would like to know whether there is any way I could ping the server from my WampSharp client?

WebSocket Server started at: 127.0.0.1:8000

Thanks in advance

1

There are 1 answers

4
darkl On

There is no supported way to do this currently.

Note that WampSharp wraps WebSocket4Net's WebSocket class, which by default automatically sends a ping message every 60 seconds.

I could not find any support for manual ping send in WebSocket4Net from the WebSocket class, but maybe it exists and I missed it.

If you want, you can find a different WebSocket client library that supports manual ping send, and implement a IControlledWampConnection that wraps it (see WebSocket4NetConnection), and use the DefaultWampChannelFactory overload that specifies the IControlledWampConnection to use (see WebSocket4Net extension methods).