Unsolved How to connect to a QWebSocketServer from the same device running it?
-
People may say this is wrong, but I want to make a program for personal use on pcs and android devices that renders its user interface in a browser, and gets the data to and from the interface via websockets from a server running on the same system (nothing is going over the internet).
To test how this could work, I started out using the "simplechat" example that comes with qt 5.15.x. It works fine when the server and the browser are both on a pc (linux or windows), and also when either the server or the browser is on a pc, and the other is on an android device.. The only time it does not work is when the server and the browser are both on an android device (whether or not they are both on one and the same android device).
Surely this can be made to work? Perhaps some extra (lax) permissions have to be granted in the android manifest? Or perhaps the page that sets up the websocket connection has to be from the same ip as the websocket server (which it is not at current since I don't have the minimal webserver required on the android and am loading that page from my desktop computer)? But that does not seem to be necessary in any of the other cases; for example, when my linux desktop successfully connects to the android web server, the page that sets it up is on one local network address and the server itself is on another.
ETA: It is not a matter of cross origin issues I think. Since I don't have a web server on the android yet, I tried for long time to just load the html file as a local file, but could not figure that out in a few hours just as apparently others have not been able to. Then I found a little web server on google play and installed it, and could serve up the html file. However, even with this file on the same domain as the QWebSocketServer, the android could not connect to it. This is looking really bad, I hope someone has an easy solution.
-
@BensonBear said in How to connect to a QWebSocketServer from the same device running it?:
People may say this is wrong, but I want to make a program for personal use on pcs and android devices that renders its user interface in a browser, and gets the data to and from the interface via websockets from a server running on the same system (nothing is going over the internet).
To test how this could work, I started out using the "simplechat" example that comes with qt 5.15.x. It works fine when the server and the browser are both on a pc (linux or windows), and also when either the server or the browser is on a pc, and the other is on an android device.. The only time it does not work is when the server and the browser are both on an android device (whether or not they are both on one and the same android device).
Surely this can be made to work? Perhaps some extra (lax) permissions have to be granted in the android manifest? Or perhaps the page that sets up the websocket connection has to be from the same ip as the websocket server (which it is not at current since I don't have the minimal webserver required on the android and am loading that page from my desktop computer)? But that does not seem to be necessary in any of the other cases; for example, when my linux desktop successfully connects to the android web server, the page that sets it up is on one local network address and the server itself is on another.
ETA: It is not a matter of cross origin issues I think. Since I don't have a web server on the android yet, I tried for long time to just load the html file as a local file, but could not figure that out in a few hours just as apparently others have not been able to. Then I found a little web server on google play and installed it, and could serve up the html file. However, even with this file on the same domain as the QWebSocketServer, the android could not connect to it. This is looking really bad, I hope someone has an easy solution.
have you fix this? i have the same issue in QWebsocketserver