Question about WebSockets clients and servers


Samuel Vanneste

Hello,
I am trying to understand why my WebSockets never receive the "Open" event. Using several other language, I can connect to my server just opening a socket.

What I receive on the server's part is way more information than just the connection. Perhaps could I send an information to AppBuilder to let it know it is connected ?

Below are the lines I get on the server. [IP] is my remote local IP

Many thanks for any help or a way to find the protocol to allow AppBuilder's app connection.


Samuel Vanneste

OK. Found what protocol I have to implement :

The WebSocket handshake (browser request and server response)

source: http://websocket.org/quantum.html

I will try to apply that plugin too : https://github.com/blocshop/sockets-for-cordova


decsoft

Hello Samuel,

I must honestly admit that my knowledge abot websockets is very limited, in particular the server side stuff. I implement the client side in App Builder because for sure websockets can be useful, that is, to maintain a connection between the application and the application's server so far than made "simply" HTTP calls.

In principle both the client side and server side must implement the HTML5 WebSocket. This is done in App Builder (for the client side) but the server is enterely out of the scope of App Builder, and, as you probably know, the WebSocket application sample uses the "echo websocket" server provided by "ws://echo.websocket.org".

So please, Samuel, just let me know if you need some help or addition in the client side in order to get your application working.



decsoft

Hello again,

One more thing Samuel: I am not sure if we need here the refered Apache Cordova's plugin... probably the WebSocket controls is enough, or I am completely wrong...?



Samuel Vanneste

Hello David,
Thanks for your replies. You are right, we don't need the pure TCP socket plugin here (this was just a workaround for me).

What I am currently have to code is the server's part (the one which will reply to AppBuilder's app to let it know it is connected). I am on.

Many thanks :)


decsoft

Hello Samuel,

If we are talking about a PHP implementation of a Websockets, then for sure I can help you at least by pointing to some useful resources. Since I imagine that we are not talking about Apache nor PHP here... I am here at your service if you need any other kind of help, for example, to perform some tests. :)



Samuel Vanneste

Just a question, David, please. Should I be able to find the reply AppBuilder is waiting, in the JavaScript Editor ? Thanks


decsoft

Hello Samuel,

I am not sure if understand well. Once we call the "SocketOpen" action, we are "waiting"... for the WebSocket control's Open event to be fired. Is something like that you need? That is, for example, we can use the SocketOpen action, then show a Progressbar control, and, hide it on the Websocket control's Open or other event like Error...

Can this help you in some way?



Samuel Vanneste

Nope David,
In the JavaScript Editor, when I search for "Socket", I find some Javascript related functions.
Because I have some trouble returning the data, AppBuilder is waiting before to fire the Open event, I was asking if, in that code, I can find the type of data it is waiting for.

Many thanks


decsoft

Hello Samuel,

Because I have some trouble returning the data, AppBuilder is waiting before to fire the Open event, I was asking if, in that code, I can find the type of data it is waiting for

I am very sorry but can't understand... no doubt by my fault. But I want to try again! What about if you use various WebSockets? In that case you know what WebSocket you are using and what type of data you are waiting for... Have this some sense? Or maybe can you explain me the issue like if I am an eight year old child.... sorry for that Samuel. :(



Samuel Vanneste

No problem at all. I can understand that my question is too large. So, please forgive me if my reply seems a bit stupid. Here is the problem :

- I make AppBuilder initiate the WebSocket connection using SocketOpen
- On the server, I get the request (as I posted above)
- Now, I have to send the reply to AppBuilder to make it fire the WebSocket.Open event

I am here and unable to find the correct data I have to return to let AppBuilder know it is connected.

So, I have thought that I could find in the app's JavaScript Editor, the description of the information required (the information I have to return).


decsoft

Hello Samuel,

Oh, that's right! Now I can understand. Thanks for your patience sir... The problem is I have no experience in Websockets server, and, the sample application uses a sample one that, apparently, provide the right reply, since the Open event is fired in the expected way.

It's ok Samuel. Let me to investigate a little more about this. My intention is to prepare a WebSocket here in hosting (using Apache and PHP in my case, but I think this no matter now) and then maybe I can tell you a little more about the possible response requeriments.

P.S. I think this question must be answered in the WebSockets HTML5 API documentation... or I am wrong... but anyway let me sometime to investigate about the issue. And please sorry any possible inconveniences.



Samuel Vanneste
P.S. I think this question must be answered in the WebSockets HTML5 API documentation...

Hello David,
Please do not spend time on the PHP part, I had not thought to check the HTML5 API documentation (I followed some tutorial about websockets). I am going to the HTML5 part immediately.
Thanks (wishing you a good evening)


decsoft

Hello Samuel,

P.S. I think this question must be answered in the WebSockets HTML5 API documentation...

Hello David,
Please do not spend time on the PHP part, I had not thought to check the HTML5 API documentation (I followed some tutorial about websockets). I am going to the HTML5 part immediately.
Thanks (wishing you a good evening)

No problem! In fact I want to do it sir. I want to know how a WebSocket server can be setup (in my case with Apache + PHP) and how they can be consumed with the App Builder WebSocket control. I will inform you about any progress on this. :)



decsoft

Hello Samuel,

Just to say that I start investigating how to setup a websocket server using PHP. The task do not appear as "easy" as I think in principle, that is, apparently it's not only a question to prepare some PHP scripts to give the appropiate response, but, on the contrary, they implied other tasks: to be honest I am not sure how to achieve it right now, so I am not saying they are difficult, I just say that I have no idea right now about how to achieve it.

But I persevere Samuel... the point is that maybe the question must be re-created (at least to me) because, if we have a websocket server running... then their behaviour must be... the expected for a websocket server running... I am not sure if can explain what I want to say. Anyway this is only a post to inform about my progress now... as I say before I will continue investigating about and hope that can prepare a PHP websocket server working... even if maybe this can't help you this time... since you do not use PHP (if I am not wrong)...

More later! :)



decsoft

Hello Samuel,

I have not very good news... first of all, I continue figuring out how to setup a websockets server with the help of PHP. However, all of what I found can't really help me to achieve that. I definitely have lacks of knowledge about the websockets technology. Apparently the server must support that, so it's not only a question to prepare the appropiate stuff, but the server must support this technology.

Another bad news is that finally I decide to try the WebSocket sample into an Android device, that is, after build the application with Apache Cordova. Unfortunatelly they doesn't work as expected (as they do in the browsers) probably because the Android's Chrome's WebView (used in Cordova) do not support the WebSocket HTML5 API, which is used by the WebSocket control in App Builder.

So in conclusion I have no idea about how to implement a WebSocket server, and, on the other hand, if we want to use it on Android devices (for example) we must use a Cordova's plugin, maybe the plugin you refer above. Certainly WebSockets appear very interesting, but not too well supported nowadays...

Maybe all of the above can help you in some way Samuel, but I think I can also help you if you provide me a sample application (which uses your Websocket server) then maybe I can view here more information about the error and then provide you some additional help about.



decsoft

Hello Samuel,

Just for your information, here is a little more about WebSockets and PHP. I find this useful article, and, certainly I can get it working using the WebSocket control of App Builder. The problem? Continue to be the same to me: certainly this WebSockets server implementation in PHP works, but, they requires a "server.php" script to be running "alone" and persistently, since they setup the WebSocket. In my opinion, another more elegant solution than this (that on the other hand can be a good sample) may must be found in order to prepare something more usable like maybe the Ratchet project.

That's all for now!



Samuel Vanneste

Hello David,
Thanks a lot for the message and the new information. I apologize for the delay (had no machine till now). :)


decsoft

Hello Samuel,

No problem! :)


Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.

This website uses some useful cookies to store your preferences.

I agree. Hide this note. Give me more information.