QT Webkit seems oblivious to new wireless network connection - qt

I am building a app that has a javascript layer on top that uses QtWebkit to occasionally access web pages; however if I start my app up without a wireless connection and then set up a connection (using ifup then a device connect then dhcpcd to get the gateway set up) the Javascript continues to be oblivious to the gateway to the wider world.
QNetworkConfigurationManager in my QtApp reports the connection is up OK after I updateConfigurations() and the IP and netmask are reported OK as well.
wget from the command prompt happily obtains whatever webpage I ask it to get.
But if I create an instance of QNetworkAccessManager then
manager->get(QNetworkRequest(QUrl("http://www.google.com/index.html"))); replies that it cannot reach the page.
Do I need to poke an update the QtWebKit somehow for the JS layer to update it's configuration as well?

The problem has been found; the implementation of Qt for embedded we have has an error in it for our implementation of uclibc. This has been patched by the (deleted for security reasons) company that supplied us with the libraries for our embedded solution.

Related

How to serve a Qt application to multiple users via Qt WebGL streaming?

Qt Quick WebGL Streaming is a technology by which any Qt Quick ("QML") application can display its user interface to a user connecting via a web browser. All you have to do is to start the application like this on the host:
./my-qml-program -platform webgl:port=8080
This works, but is limited by design so that only one user can be connected at the same time and see the user interface. As the reason for this, they quote problems with user input, with querying the GPU, and with security (source).
Initially, the Qt developers wanted to support multiple users in WebGL streaming by serving multiple windows from one process:
How will concurrency be supported? Like does each connection get it's own QGuiApplication, or is there only one? […] You create a single QGuiApplication and different windows. There is a signal to notify when new clients connect to the HTTP server. When the signal is emitted, you create a different QWindow. The windows are independent (source)
Now however, the developers want to support multiple users in WebGL streaming by launching one process per user.
We are working in decoupling the HTTP Server from the plugin
A dedicated HTTP Server application will be provided
Instead of running all the users in the same process a new process will be spawned per user
The new process will handle the web socket
(source)
"Decoupling the HTTP Server from the plugin" would mean replacing it with QHttpServer:
I have planned some use-cases for this [QHttpServer] module: Change the current embedded web server (and WebSockets) in the WebGL plugin to make it easy to create your own custom solutions based on the plugin. (source)
So far, no solution has been implemented. What is the simplest way to implement support for multiple users in Qt WebGL streaming myself, without waiting for Qt to implement this?
Here is a solution that uses the load balancer Pen to make a Qt application accessible via WebGL streaming to multiple users at the same time. It forwards an incoming connection to one of multiple Qt processes running on the same host, each of which running its own embedded web server. This kind of forwarding is exactly the job of a load balancer, just that it usually distributes connections to multiple hosts.
Caveat: In my tests, WebGL streaming in Qt 5.12.3 is fast enough for real use only in the local network, not over Internet. So you can't use it to "convert a Qt application into a web application on the cheap".
Instructions
These instructions apply to Ubuntu 19.10, 20.04 and other Debian based distributions.
Install the Qt application on your web host.
Install the Qt WebGL platform plugin on your web host. It is not contained in the Ubuntu 19.10 distribution, for example. In such a case, you'd have to compile and install it yourself. Under Ubuntu Linux, the result should be the following file:
/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqwebgl.so
Start multiple processes of the Qt application. Each should serve one port with Qt WebGL streaming. Here we start three processes, but you can start as many as fit into your memory.
nohup myapplication -platform webgl:port=8080 &
nohup myapplication -platform webgl:port=8081 &
nohup myapplication -platform webgl:port=8082 &
Install the load balancer Pen.
sudo apt install pen
Start the load balancer. Note that with pen 80 … it is started so that the users only have to enter a simple URl such as http://example.com/ into their web browser to visit the application. If port 80 is already in use, you can choose any other port (say, 9090), start the load balancer with pen 9090 … and then let users visit a URL like http://example.com:9090/. Also note the :1:1 suffix for each server process listed, telling pen to only connect at most one client to one process.
pen 80 localhost:8080:1:1 localhost:8081:1:1 localhost:8082:1:1
Test the setup. To test, visit the associated URL http://example.com/ from multiple devices. You shoud be served one process of the application on each device. It is not possible to see two processes in two parallel browser tabs on the same device – pen would then try to connect the second such tab to the same Qt process as the first tab because the request comes from the same IP address. As a result, you'd see a spinning wheel in the second tab, because Qt processes only allow one connection each for WebGL streaming.
Improvements
This solution could be further improved by starting the Qt processes only on demand, once a client connects. This should be possible with systemd socket activation.

Electron js offline network with pouchdb

I've created an electronjs app with pouchdb. The intent of this desktop app is to work within a wireless network of tablet application that share the same data that is pretty much blocked from the internet 95% of the time (hence the pouchdb implementation). In order for the tablet applications to sync with the desktop app, they need to be aware of how to connect to the desktop app within the network. My initial thought would be to broadcast the IP address of the electron js app in order to share data within pouchdb, but I'm not sure if it's possible. I am also thinking that I'll could install couchdb as a separate instance on the network, but would like to keep set up as simple as possible. Any ideas on how I can set this up with electron js and pouchdb?
You might be able to achieve the desired result using the Multicast DNS discovery service with Node. With mDNS, you can query the local network for other devices broadcasting on a specific namespace (e.g. 'myappid.local') which the application could query the network for.
multicast-dns is a module capable of querying the network for other devices broadcasting under a name and getting their local IP address.
After establishing a connection to other application instances on the same network, you could try replicating the database over that connection. A PouchDB plugin might be required for getting this data from Electron's main process to the renderer.

Disable internet access when calling java -jar

I'm testing six distinct .jar-files that all need to handle the possibility of no online access.
Unfortunately, I am on a network disc, so disabling the network connection or pulling the ethernet cable does not work unless I move all the files to /tmp or /scratch and change my $HOME environment variable, all of which I'd rather not have to do as it ends up being a lot of work.
Is there a way to invoke java -jar and disable the process from accessing the internet? I have not found any such flag in the man-pages. Is there perhaps a UNIX-way of doing this, as in:
disallowinternetaccess java -jar Foo.jar
Tell your Java program to access the network through a proxy. For all internet access this would be a SOCKS5 proxy.
java -DsocksProxyHost=socks.example.com MyMain
I believe that if no proxy is running you should get an appropriate exception in your program. If you need full control of what is happening, you can look into - and possibly modify - http://jsocks.sourceforge.net/
See http://docs.oracle.com/javase/7/docs/technotes/guides/net/proxies.html for details.
Note: You can do this without any native Unix stuff, so this question fits perfectly fine on SO.
You need just turn on SecurityManager: -Djava.security.manager=default
see details - https://stackoverflow.com/a/4645781/814304
With this solution you can even handle which resource you want to show and which to hide.

Accessing Serial Ports with an Application Runs in Flatpak

I recently updated my IDE to Monodevelop 6 using Flatpak, on Ubuntu 16.04 LTS, from an older version 5.
I have an application that interacts with serial ports which is basically a USB/RS232 adapter connecting a device to my computer.
I have no issue accessing USB port (/dev/ttyUSB0) when I debug the application in Monodevelop5. However, the device directory (/dev/) that I have access to, using Monodevelop6 is completely different than the one I have access to in Linux, and there is no ttyUSB0 in that folder.
I believe this is because Flatpak runs the application in sandbox. So, if that is the reason, how can I access to a serial port then?
Thanks.
Most likely that's because Flatpak is blocking access to the serial device.
Unfortunately at the moment I don't think there is a way to give access specifically to the serial devices, so you'd need to give access to all:
$ flatpak run --device=all com.xamarin.MonoDevelop
What this does is essentially mount the host's /dev inside the sandbox, so the app has full access to it.
It's a pretty big hole in the sandbox, but sometimes it's needed until all the permission handling stuff gets implemented.

Creating a GPRS Connection using Windows Mobile 6.5

I am writing an application in which I need to make a GPRS connection.
Can someone please help me how I can setup this connection using C#.
thanks
EDIT
I will need to connect a GPRS connection because I need to call a webservice.
To make a GPRS connect using a dial up connection subsystem from .NET CF on PocketPC, you can use Connection Manager functions such as ConnMgrEnumDestinations, ConnMgrEstablishConnection and ConnMgrReleaseConnection. Check out http://msdn.microsoft.com/library/default.asp?url=/library/en-us/APISP/html/sp_cnmn_connection_manager.asp for details. There are no classes available for this in .NET CF, but it can be done quite easily using P/Invoke if you have some experience with this.
The following blog post covers this in detail and also contains some C# code: http://blogs.msdn.com/anthonywong/archive/2006/03/13/550686.aspx.
Another solution is using the Smart Device Framework by OpenNETCF.org that contains a wrapper class for the Connection Manager:
http://www.opennetcf.org/downloads/bin/SmartDeviceFramework14.zip
It is free for any commercial or noncommercial purpose up to the version 1.4. It also includes the source code, so you might either use it as is or as a reference for your own implementation if you prefer.
(solution taken from our website at http://forum.rebex.net/questions/503/how-to-establish-a-gprs-connection-for-ftp-use-on-net-cf)
This page might help...
http://msdn.microsoft.com/en-us/library/bb840031.aspx
Is it really important to explicitly create that connection? If you initiate any outgoing (eg. not localhost) connection (like a HttpWebRequest), the OS will automatically connect to the Internet using the preferred connection, which can be GPRS.

Resources