PureBasic and wss websocket?

Just starting out? Need help? Post your questions and find answers here.
nimda
New User
New User
Posts: 7
Joined: Thu Aug 23, 2018 12:13 am

PureBasic and wss websocket?

Post by nimda »

Hello,

I need to access a secured websocket server (wss), is PureBasic able to do that?

Thanks :)
User avatar
idle
Always Here
Always Here
Posts: 5094
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: PureBasic and wss websocket?

Post by idle »

not natively but there are user libs that support websockets
Windows 11, Manjaro, Raspberry Pi OS
Image
infratec
Always Here
Always Here
Posts: 6871
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PureBasic and wss websocket?

Post by infratec »

viewtopic.php?f=27&t=64185&hilit=websocket

in cooperation with stunnel.
nimda
New User
New User
Posts: 7
Joined: Thu Aug 23, 2018 12:13 am

Re: PureBasic and wss websocket?

Post by nimda »

Ok, so there's a couple ways to bypass this constraint. Thanks! :wink:

As a PureBasic newbie, I'll probably give a try to Stunnel before messing around with libs... :mrgreen:

Also (just to make sure), OpenNetworkConnection() supports server names with path, right? (ex: http(or ws)://server.com/one/long/path/withf@ncycharacter)
User avatar
NicTheQuick
Addict
Addict
Posts: 1226
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: PureBasic and wss websocket?

Post 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.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
nimda
New User
New User
Posts: 7
Joined: Thu Aug 23, 2018 12:13 am

Re: PureBasic and wss websocket?

Post 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?
User avatar
NicTheQuick
Addict
Addict
Posts: 1226
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: PureBasic and wss websocket?

Post 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.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
nimda
New User
New User
Posts: 7
Joined: Thu Aug 23, 2018 12:13 am

Re: PureBasic and wss websocket?

Post 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! :D (did you know websocket servers are case sensitive..? :mrgreen:)

Thank you everybody for the help! :wink:
nimda
New User
New User
Posts: 7
Joined: Thu Aug 23, 2018 12:13 am

Re: PureBasic and wss websocket?

Post 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?
vwidmer
Enthusiast
Enthusiast
Posts: 282
Joined: Mon Jan 20, 2014 6:32 pm

Re: PureBasic and wss websocket?

Post 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
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA
Post Reply