Page 1 of 1
PureBasic and wss websocket?
Posted: Thu Aug 23, 2018 12:32 am
by nimda
Hello,
I need to access a secured websocket server (wss), is PureBasic able to do that?
Thanks

Re: PureBasic and wss websocket?
Posted: Thu Aug 23, 2018 2:07 am
by idle
not natively but there are user libs that support websockets
Re: PureBasic and wss websocket?
Posted: Thu Aug 23, 2018 6:40 am
by infratec
Re: PureBasic and wss websocket?
Posted: Thu Aug 23, 2018 12:06 pm
by nimda
Ok, so there's a couple ways to bypass this constraint. Thanks!
As a PureBasic newbie, I'll probably give a try to Stunnel before messing around with libs...
Also (just to make sure), OpenNetworkConnection() supports server names with path, right? (ex: http(or ws)://server.com/
one/long/path/withf@ncycharacter)
Re: PureBasic and wss websocket?
Posted: Thu Aug 23, 2018 12:30 pm
by NicTheQuick
No, it does not. It simply connects to a host using a hostname or IP address. Paths only exist in the environment of a protocol like HTTP(S), (S)FTP, WebDAV and so on. But OpenNetworkConnection() is much more low level.
Re: PureBasic and wss websocket?
Posted: Thu Aug 23, 2018 2:17 pm
by nimda
Oh ok, I see... I guess I have to use SendNetworkString() (string being: /one/long/path/withf@ncycharacter) once connected to host, to access the stream?
Re: PureBasic and wss websocket?
Posted: Thu Aug 23, 2018 2:42 pm
by NicTheQuick
No, this is not how this works. It is much more complicated than this. But I am not able to teach it to you here. Let's see if an other user has a good idea to solve your issue.
Re: PureBasic and wss websocket?
Posted: Thu Aug 23, 2018 4:24 pm
by nimda
Ah... Well, I'll try to find more about websocket syntax. Thanks anyway!
BTW, this is where I want to connect, if that helps:
https://github.com/binance-exchange/bin ... streams.md Maybe it's obvious for coding gurus, but it's not for beginners...
edit: Hmm.. Well,
Netzvamp's code (with Stunnel for wss) works great actually!

(did you know websocket servers are case sensitive..?

)
Thank you everybody for the help!

Re: PureBasic and wss websocket?
Posted: Sat Aug 25, 2018 10:19 am
by nimda
Hu ho... It seems something is wrong with memory, I get errors after a few seconds.
Code:
https://gist.github.com/Netzvamp/8623def14501de15c9e4
(code is 3 years old...)
(...)
[10:37:43] [ERROR] module_websocketclient.pb (Line: 337)
[10:37:43] [ERROR] Invalid memory access. (read error at address 18446744073709551615)
[10:37:58] The Program was killed.
[10:37:59] Waiting for executable to start...
[10:37:59] Executable type: Windows - x64 (64bit, Unicode)
[10:37:59] Executable started.
[10:38:29] [ERROR] module_websocketclient.pb (Line: 337)
[10:38:29] [ERROR] Invalid memory access. (read error at address 18446744073709551615)
[10:38:32] The Program was killed.
[10:38:35] Waiting for executable to start...
[10:38:35] Executable type: Windows - x64 (64bit, Unicode)
[10:38:35] Executable started.
[10:39:28] [ERROR] module_websocketclient.pb (Line: 273)
[10:39:28] [ERROR] Invalid memory access. (write error at address 73015296)
Any idea of what's wrong?
Win 7/x64, PureBasic 5.62 (x64)
I'm no expert but I can see some AllocateMemory() functions in loops (especially Repeat/ForEver) and no FreeMemory() function. The program is supposed to run 24/7, isn't it going to fulfill memory?
Re: PureBasic and wss websocket?
Posted: Tue Jul 09, 2019 12:32 pm
by vwidmer
idle wrote:not natively but there are user libs that support websockets
Anyone know what user libs these are that work with wss?
Thanks