It is currently Mon Jul 16, 2018 9:28 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: WebSocket Server
PostPosted: Thu Jun 16, 2016 3:11 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Feb 19, 2010 3:42 am
Posts: 472
If I only asked earlier...
Now it works seemless!

I got strange client side disconnects in the browser; and information there is somewhat... less.

Thanks a lot for the new code and Your help!!!


Top
 Profile  
Reply with quote  
 Post subject: Re: WebSocket Server
PostPosted: Thu Jun 16, 2016 3:26 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Feb 19, 2010 3:42 am
Posts: 472
How do I get the data sent from the client?

The public structure Event_Frame is used then?

Maybe too easy...


I am at that point; of course not only text but data...
Code:
 Event_Frame\Payload = *Object\Client()\RX_Frame()\Data + *Object\Client()\RX_Frame()\Payload_Pos
          Event_Frame\Payload_Size = *Object\Client()\RX_Frame()\Payload_Size
         
          *Callback(*Object, *Object\Client(), #Event_Frame, Event_Frame)
         
          FreeMemory(*Object\Client()\RX_Frame()\Data)



Oh man, it's PeekS(..., -1, #PB_Ascii)...

The browser dares to send ascii that...

O.k. works now; thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: WebSocket Server
PostPosted: Wed Jun 29, 2016 10:24 am 
Offline
Enthusiast
Enthusiast

Joined: Fri Feb 19, 2010 3:42 am
Posts: 472
Hello,

just a little "problem".

In WebSocket_Server.pbi at this point:
Code:
debug peeks(*Object\Client()\RX_Frame()\Data, -1, #PB_Ascii)

in
Code:
Procedure Event_Callback(*Object.Object, *Callback.Event_Callback)

I get this result:
Code:
‰C²+§Test send²+§


After all threads done I am in my callback and do this:
Code:
*WSE\Text = PeekS(*Event_Frame\Payload, -1, #PB_Ascii)

I get this result:
Code:
Test send²+§


Do the 3 characters at the end still belong to the protocol and can I strip them off simply?

Damn... got the problem writing this...
Payload size has to be used in peeks...

Will keep it in the forum...


Top
 Profile  
Reply with quote  
 Post subject: Re: WebSocket Server
PostPosted: Tue Jul 12, 2016 3:39 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Aug 15, 2009 6:59 pm
Posts: 1243
Dadido3 wrote:
Thorium wrote:
Will you add TSL?

It's planned, but i can't say when i'll add it.

Edit:
If TLS is needed you can use a webserver as proxy. For NGINX this may be helpful: http://stackoverflow.com/questions/12102110/nginx-to-reverse-proxy-websockets-and-enable-ssl-wss. But i haven't tried it.


Since TLS is very important for my webservice i am using libwebsockets now. Finaly got it to compile. Compiling OpenSSL was a pain. Currently i am translating the example server from c to PB.


Top
 Profile  
Reply with quote  
 Post subject: Re: WebSocket Server
PostPosted: Fri May 19, 2017 7:11 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed Aug 03, 2011 4:52 am
Posts: 184
Location: Beirut, Lebanon
hello:
project doesn't compile with PB5.60: error: Base64Encoder(): Incorrect number of parameters.

any trick?
thanks

_________________
PureBasic: Surprisingly simple, diabolically powerful


Top
 Profile  
Reply with quote  
 Post subject: Re: WebSocket Server
PostPosted: Fri May 19, 2017 11:44 pm 
Offline
User
User
User avatar

Joined: Sat Jan 12, 2008 11:50 pm
Posts: 42
Location: Hessen, Germany
Hi morosh,

replace Base64Encoder with Base64EncoderBuffer. Or just redownload, as i have updated the include.

_________________
Website


Top
 Profile  
Reply with quote  
 Post subject: Re: WebSocket Server
PostPosted: Sat May 20, 2017 9:25 am 
Offline
Enthusiast
Enthusiast

Joined: Wed Aug 03, 2011 4:52 am
Posts: 184
Location: Beirut, Lebanon
Thank you

_________________
PureBasic: Surprisingly simple, diabolically powerful


Top
 Profile  
Reply with quote  
 Post subject: [SOLVED] WebSocket Server
PostPosted: Fri Aug 11, 2017 9:09 am 
Offline
Enthusiast
Enthusiast

Joined: Fri Feb 19, 2010 3:42 am
Posts: 472
WebSocket does not work; using AJAX instead...



I use the example given with the WebSocket_Server code.

In Internet Explorer 11 I got this problem:
"SCRIPT12008: WebSocket Error Status Code 403, Not Found"
(When I put nonsense URL I get correct error "... Code 200 ...".)

In the PureBasic code the events are triggered!


Any idea?
I know that's no problem with PureBasic / WebSocket Server.

Put I could not find any solution.

Btw., Firefox works!

Any help really apreciated!


Top
 Profile  
Reply with quote  
 Post subject: Re: WebSocket Server
PostPosted: Tue Sep 19, 2017 2:46 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Feb 19, 2010 3:42 am
Posts: 472
"WebSocket does not work; using AJAX instead..."

To make things clear; the websocket server source post works of course!

My local config of internet explorer 11 is crazy and can not be changed.

Seems like it does not work with local web socket server while Firefox, Vivaldi works and IE11 works with echo websocket site.


Top
 Profile  
Reply with quote  
 Post subject: Re: WebSocket Server
PostPosted: Fri Oct 27, 2017 2:31 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Apr 30, 2003 8:15 am
Posts: 954
Location: Germany
@Dadido3: thanks! Works fine with PB 5.45 :D

If someone is interested in webapps, I built a chat client for the server with SpiderBasic for testing purposes:
http://forums.spiderbasic.com/viewtopic.php?f=12&t=1362

_________________
"Daddy, I'll run faster, then it is not so far..."


Top
 Profile  
Reply with quote  
 Post subject: Re: WebSocket Server
PostPosted: Thu Dec 07, 2017 11:27 am 
Offline
User
User

Joined: Mon Aug 31, 2009 2:11 pm
Posts: 78
1. My site is only HTTPS://www.example.com/chat.html
2. PB is running as ws://

How do you enable `WSS://` on the existing PB server?
(without hacking nginx, stunnel, proxy server's, not depending on third party tools absolutely natively with PB)

_________________
-----
Registered PureBasic Coder.


Top
 Profile  
Reply with quote  
 Post subject: Re: WebSocket Server
PostPosted: Thu Feb 22, 2018 3:01 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Aug 15, 2009 6:59 pm
Posts: 1243
shamun wrote:
1. My site is only HTTPS://www.example.com/chat.html
2. PB is running as ws://

How do you enable `WSS://` on the existing PB server?
(without hacking nginx, stunnel, proxy server's, not depending on third party tools absolutely natively with PB)

You can't enable it. WSS uses TLS which the server posted here is not supporting and doing it without any third party tools/libs is a pretty big project.
I ended up using libwebsocket but you need to work your way through compiling openssl first, it was a pain. Compiling of libwebsocket was easy.


Top
 Profile  
Reply with quote  
 Post subject: Re: WebSocket Server
PostPosted: Tue Feb 27, 2018 11:27 pm 
Offline
User
User

Joined: Sat Oct 18, 2014 7:14 am
Posts: 15
The server hangs up after a short time.
How can I do it without thread?


Top
 Profile  
Reply with quote  
 Post subject: Re: WebSocket Server
PostPosted: Wed Feb 28, 2018 8:15 pm 
Offline
User
User
User avatar

Joined: Sat Jan 12, 2008 11:50 pm
Posts: 42
Location: Hessen, Germany
I have tried to reproduce that bug, but i wasn't able to do so on Windows or Linux, even with over 100 clients. But while looking over the code i found a possible deadlock case which i fixed. (Double locking of a mutex from the same context)
There were also some other small things which i fixed and optimized, so it shouldn't hurt to update.

I also added a description and an example on how to use polling instead of the threaded callback. In case of polling, the include still uses threading internally, but the event callback will be called from whatever context you wish.

_________________
Website


Top
 Profile  
Reply with quote  
 Post subject: Re: WebSocket Server
PostPosted: Thu Mar 01, 2018 9:45 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue May 28, 2013 10:51 pm
Posts: 517
Location: Europe
Dadido3 wrote:
I have tried to reproduce that bug, but i wasn't able to do so on Windows or Linux, even with over 100 clients.
Hi Dadido3,

could you please clarify what is the particular constraint for number of concurrent users? Protocol itself, programming or hardware limitation?

_________________
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye