PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WEBDEV 2024 → WebDev v2 Websockets
WebDev v2 Websockets
Débuté par Anthony, 13 juin 2017 17:37 - 4 réponses
Membre enregistré
4 messages
Posté le 13 juin 2017 - 17:37
Hi ,

OK Websockets I get an error, and been trying for couple of days.

I use Windev code from here:
https://doc.pcsoft.fr/en-US/?1000017192

Webdev code from here:
https://doc.pcsoft.fr/en-US/?1000017192

I see TCP connection established using netstat -n

I trace that socket which exists and it does.

I get this error when I try to socket write:

Error in the browser code:
Vous avez appele la function SocketEcrit.
La Socket de nom client1 n'est pas encore connecte.

The code I use is:

// Global Proc

Procedure SendSocketMessage(sMessage)
IF SocketWrite("client1",sMessage) THEN
Trace("message sent")
ELSE
Trace(SocketError)
END






// Global Proc

Procedure ReceptionMessage(nEvent, sMessage)

gsRes is string = ""

Trace(nEvent)
Trace(sMessage)

SWITCH nEvent
CASE SocketOpening:
SocketWrite("client1", "Text of message sent from the browser.")
Trace("Write to socket")
RETURN
CASE SocketMessage: gsRes += [CR] + "Receiving message: " + sMessage

CASE SocketClosing: gsRes += [CR] + "Closing the socket"

CASE SocketError: gsRes += [CR] + "Error of socket: " + sMessage
RETURN
OTHER CASE
gsRes += [CR] + "other cases: " + sMessage
END
Trace(gsRes)




I have tried this onLoad on a page and I am using it in Browser declaration, whether its there
or Onload on a page same error writing to the socket

IF SocketExist("client1") = False THEN
SocketConnect("client1", "ws://46.17.216.202:5010/test", ReceptionMessage,"JSON")
END


Any idea please ....

Thank you !

Tony
Posté le 13 juin 2017 - 19:49
Hi Anthony

try testing the return of the spcketconnect function, as it seems it's
not working

the help gies an example :

IF SocketConnect("Server", 8000) = False THEN
Error("Connection error" + ErrorInfo(errMessage))
END


Le 6/13/2017 à 9:37 AM, Anthony a écrit :
Hi ,

OK Websockets I get an error, and been trying for couple of days.

I use Windev code from here:
https://doc.pcsoft.fr/en-US/?1000017192

Webdev code from here:
https://doc.pcsoft.fr/en-US/?1000017192

I see TCP connection established using netstat -n

I trace that socket which exists and it does.

I get this error when I try to socket write:

Error in the browser code:
Vous avez appele la function SocketEcrit.
La Socket de nom client1 n'est pas encore connecte.

The code I use is:

// Global Proc

PROCEDURE SendSocketMessage(sMessage)
IF SocketWrite("client1",sMessage) THEN
Trace("message sent")
ELSE
Trace(SocketError)
END






// Global Proc

PROCEDURE ReceptionMessage(nEvent, sMessage)

gsRes is string = ""

Trace(nEvent)
Trace(sMessage)

SWITCH nEvent
CASE SocketOpening: SocketWrite("client1", "Text of message
sent from the browser.")
Trace("Write to socket")
RETURN
CASE SocketMessage: gsRes += [CR] + "Receiving message: " + sMessage

CASE SocketClosing: gsRes += [CR] + "Closing the socket"

CASE SocketError: gsRes += [CR] + "Error of socket: " + sMessage
RETURN
OTHER CASE
gsRes += [CR] + "other cases: " + sMessage
END
Trace(gsRes)




I have tried this onLoad on a page and I am using it in Browser
declaration, whether its there or Onload on a page same error writing to
the socket

IF SocketExist("client1") = False THEN
SocketConnect("client1", "ws://46.17.216.202:5010/test",
ReceptionMessage,"JSON")
END


Any idea please ....

Thank you !

Tony
Membre enregistré
4 messages
Posté le 22 juin 2017 - 00:34
Fabrice Harari wrote:
Hi Anthony

try testing the return of the spcketconnect function, as it seems it's
not working

the help gies an example :

IF SocketConnect("Server", 8000) = False THEN
Error("Connection error" + ErrorInfo(errMessage))
END


Le 6/13/2017 à 9:37 AM, Anthony a écrit :
Hi ,

OK Websockets I get an error, and been trying for couple of days.

I use Windev code from here:
https://doc.pcsoft.fr/en-US/?1000017192

Webdev code from here:
https://doc.pcsoft.fr/en-US/?1000017192

I see TCP connection established using netstat -n

I trace that socket which exists and it does.

I get this error when I try to socket write:

Error in the browser code:
Vous avez appele la function SocketEcrit.
La Socket de nom client1 n'est pas encore connecte.

The code I use is:

// Global Proc

PROCEDURE SendSocketMessage(sMessage)
IF SocketWrite("client1",sMessage) THEN
Trace("message sent")
ELSE
Trace(SocketError)
END






// Global Proc

PROCEDURE ReceptionMessage(nEvent, sMessage)

gsRes is string = ""

Trace(nEvent)
Trace(sMessage)

SWITCH nEvent
CASE SocketOpening: SocketWrite("client1", "Text of message
sent from the browser.")
Trace("Write to socket")
RETURN
CASE SocketMessage: gsRes += [CR] + "Receiving message: " + sMessage

CASE SocketClosing: gsRes += [CR] + "Closing the socket"

CASE SocketError: gsRes += [CR] + "Error of socket: " + sMessage
RETURN
OTHER CASE
gsRes += [CR] + "other cases: " + sMessage
END
Trace(gsRes)




I have tried this onLoad on a page and I am using it in Browser
declaration, whether its there or Onload on a page same error writing to
the socket

IF SocketExist("client1") = False THEN
SocketConnect("client1", "ws://46.17.216.202:5010/test",
ReceptionMessage,"JSON")
END


Any idea please ....

Thank you !

Tony





Hi Fabrice,

Thank you for your answer.

We cannot not use the following it's not allowed in browser code.

IF SocketConnect("Server", 8000) = False THEN
Error("Connection error" + ErrorInfo(errMessage))
END


I have copied both the browser connect code and the windev server code from this example:

https://doc.pcsoft.fr/en-US/?1000017192

The browser (Chrome) says connected then disconnected. I have wiresharked the connection and the TCP disconnects, so I am unable to send a websocket message either direction and I am very frustrated. I am not 100% sure the TCP connection/negotiation completes. There is no sensible reported error messages either from the Windev websocket server, nor from the browser trace. (I really don't want to use Node.JS, I really want to use a Windev websocket server). To do this I at least need an example to work with a basic connection so I can build on that.

I have used identical code from this example for both the browser websocket connection to a
windev websocket server.

Do you you know of anyone (PCsoft for example) may be who has a windev example that allows a websocket in Webdev 22 to work?

Unfortunately there is no example in Windev 22 in the installed example applications list.

There are no examples and the example with exact copied code on Windev website help appears not to work.

Such a good opportunity and feature but unable to get it to work.

Thank you

regards

Tony Turner
Membre enregistré
18 messages
Popularité : +1 (1 vote)
Posté le 23 juin 2017 - 06:03
Are your running Version 22? We've had an issue since updating from the Pre-Release to the Final Version (both in WebDev IDE and WebDev Server). We have Sockets that talk to linux servers. They send a command(s) and then we have a thread that waits to get a confirmation response from the server. Ever since the update this has broken. It sends fine, but the thread to listen just stays open and never exits. It actually causes lockup of our Linux servers. We've had this code in place for 6 years through V14 and every upgrade along the way. The only thing updated was the WebServer and IDE. If we roll back the server to pre-release and run pre-release compiled code it works. Running final release IDE code on the Pre-Release server and it stops working as well.

For now we've had to remove the Listener (fire and forget) as a workaround. Opened a Support incident 3 days ago and haven't heard anything back.
Posté le 23 juin 2017 - 10:20
Hi Stephen,

Thank you for your answer.

yes v22 on Webdev and Windev. It appears to connect, even the webdev socket server (PCSoft code) says connected but then says disconnected from other side, i.e browser websocket. No sensible method to find why.

It should not be this hard I have been writing UDP and TCP socket applications in Windev since version 11 every day
every year. 10x faster or 100x slower, frustrated.

I struggle to see how copied code off the PCSoft site which has loads of spelling mistakes should not be correct and working.

My version English v22 upgrade m.

I have sent PCSoft the Webdev test app and test Windev app.

regards

Tony