1

I am trying to write a very simple WebSocket client with VB.NET but couldn't find a ready-to-use webSocket control.

There is one control that does exactly what I am looking for: IP*Works! WS from nSoftware, but unfortunately they charge a fortune for it.

Here is a screenshot of the demo app they provide:

enter image description here

Question: Does anyone know of a similar free/low-budget .NET control to do the same ?

Note: I have tested this demo app with VB.NET and it works flawlessly connecting to: ws://echo.websocket.org

edit: Also, I would remain interested in hearing from XOJO/RealBasic, Xamarin and LiveCode users for a similar solution that actually works with this server -> ws://echo.websocket.org

Jack M.
  • 3,676
  • 5
  • 25
  • 36
  • I'm able to open a socket to echo.websocket.org with LiveCode, but I don't know what to send to get a response. If you provide more information about the protocol, I should be able to provide you with a complete answer. – Mark Jul 13 '14 at 09:09
  • As an example regarding protocol, I open a socket to echo.websocket.org, which seems to work. If I open a socket to echo.websocket.org:4444, I get a timeout. This means that I'm able to connect. If I write "helo"&crlf to the socket, I get no response. I need to know which port to use and what command to use to shake hands with the server. – Mark Jul 13 '14 at 09:13
  • Same thing happens to me. Ok it is port 80 and they provide all socket spec details in their website. You can download this client example (check source code for port number) http://www.filedropper.com/ws – Jack M. Jul 13 '14 at 09:19
  • What I really need is a list of commands that I can send to the server. Unless you can tell me exactly where to find this list of commands, I'm not downloading anything. – Mark Jul 13 '14 at 09:21
  • If you send an ASCII message, server will reply with the same message ;) – Jack M. Jul 13 '14 at 09:30
  • I try this and all I get is an EOF. Can you give an exact example of data that works with your own tests? – Mark Jul 13 '14 at 09:53
  • I have tested this -> https://www.nsoftware.com/ipworks/ws/ using VB.NET. Installation comes with that working example. – Jack M. Jul 13 '14 at 10:27
  • Sorry, but that link doesn't provide me with any information about what one might send to the server. I don't need links to software, I need a document with the description of the protocol, and only that. – Mark Jul 13 '14 at 10:30
  • 1
    http://datatracker.ietf.org/doc/rfc6455/?include_text=1 – Jack M. Jul 13 '14 at 10:32
  • The problem appears to be in the headers. – Mark Jul 13 '14 at 10:48

2 Answers2

2

Your own tests with RealStudio and my tests with LiveCode don't work (so far) because with every request you need to send headers. The headers that the client needs to send to shake hands with the server are

    GET /chat HTTP/1.1
    Host: server.example.com
    Upgrade: websocket
    Connection: Upgrade
    Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
    Origin: http://example.com
    Sec-WebSocket-Protocol: chat, superchat
    Sec-WebSocket-Version: 13

Probably, you can set the httpHeaders in LiveCode and use simple put/get URL commands to communicate with the server. I will try this and will edit my answer later.

Another LiveCode solution is to set the html of a revBrowser control and call the JavaScript function from a LiveCode script using the revBrowserExecuteScript() function.

Mark
  • 2,380
  • 11
  • 29
  • 49
  • 1
    I was suspecting exactly the same. A solution to send httpHeader using XOJO would be highly appreciated, but with LiveCode its ok too. Thank you so much in advance for your time. Thanks x999++ – Jack M. Jul 13 '14 at 10:54
  • Anyway, I will still working on this / googling / reading until I find a solution – Jack M. Jul 13 '14 at 11:01
  • 1
    For Xojo, HTTPSocket.SetRequestHeader lets you specify the header. I have no idea if this will help with your WebSocket issue, though. – Paul Lefebvre Jul 16 '14 at 14:27
  • I tried this in LiveCode, @PaulLefebvre, but it seems to be insufficient. – Mark Jul 17 '14 at 07:23
  • @Paulo Lefebvre in Xojo I am doing differently with Dim headers As New InternetHeaders and then headers.SetHeader("Upgrade:", "websocket") ... and so on. I can establish connection and get the 101 header from server but connection is dropping after few seconds :( – Jack M. Jul 18 '14 at 13:28
  • Update: I believe the problem is related with the PONG reply which is not masked yet. I will try to sort it out. – Jack M. Jul 18 '14 at 13:33
1

Ok, after a few days working on this I figured it out:

  • With VB.NET there are a lot of libraries and information available throughout and there are some ready to use controls available. Nsoftware has a very good one but is too expensive. The free controls are not that good and most of them outdated (old specs). The best thing to do is write the specs manually but the existing demos, documentation and libraries are extremely helpful.

  • With XOJO there is no such thing like a ready to use control so I had to use the TCP Socket control and implement the specification manually. It is working okay now thanks to the community since it's help articles are rubbish.

  • I did not took much time doing tests in LiveCode but I believe the problem is the same. Since there is no ready to use controls available, at least as far as I know, I'd probably had to write the specification manually in Live Code like I did in Xojo.

Basically, although not easy, it is possible in any programming language I would guess.

Jack M.
  • 3,676
  • 5
  • 25
  • 36