Can't launch server QWsServer error : The address is protected - android

I'm trying to do a C++ websocket server. I want to "speak" to an android Application and send it videos.
I'm using QtWebsocket from this repository
To test, I copied the code from Example/Server.
I haven't had any compilation error but the server cannot start:
Error: Can't launch server QWsServer error : The address is protected
I am beginner in network and websockets.

The port you are trying to listen on -> 80 is available only to privileged applications (and only if no other process is listening on it). Try using different port (ex. 8080), or running your application as root.
For more info about ports check out: Privileged Ports

Related

Flutter "Connection Refused" (errno=111) when trying to send an http get request to from physical device to pc

I built a flutter app which communicates with a web server that I wrote with flask. Everything works as intended without any errors if I use a virtual device. As soon as I try it in release mode on a physical device I get problems when it comes to the communication with the server
The only thing that I changed when using a physical device is the ip. I use 10.0.2.2 on the virtual device and my computers ip4 adress - that I get with ipconfig in windows 10 - on the physical device
Both devices are in the same network connected to the same router
Internet Permission is enabled in the AndroidManifest for all modes (Debug, Main, Profile)
I even disabled the firewall
The line that causes the issue is
await http.get(url).timeout(Duration(seconds: 15), onTimeout: () {
// Handle timeout
// This entire thing is in a try-catch block in an async function
});
In debug mode on the physical device when the HTTP get request is sent VSCode immediately says
Exception has occurred.
SocketException (SocketException: OS Error: Connection refused, errno = 111, address = 192.168.178.20, port = 43378)
First Question: Why Port 43378? Is that the port the HTTP request is sent to? Because when I run the flask app it says:
Running on http://127.0.0.1:5000/
Could that be the issue? I would have expected the exception to say the port is 5000 as declared in the URL. Or do I have to change something with how I set up the flask app? Currently it is the development server because I am still testing before I pay money and deploy
However I hope I didnt forget any important information. Any advice on what could be wrong or how to debug here is highly aprecciated
Pass an Uri object to http.get func. Uri classes let you specify the port as Documentation https://api.dart.dev/stable/2.12.0/dart-core/Uri-class.html

Stream resumption in ejabberd is not working

First Case:
I am using PSI client in Ubuntu 16.04 LTS and my ejabberd version is 16.03.
I am facing message lost issues hence i have gone through this link for stream management : http://xmpp.org/extensions/xep-0198.html
When i send following request
<enable xmlns='urn:xmpp:sm:3' resume='true'/>
Server response is ok for me, i.e
<enabled xmlns="urn:xmpp:sm:3" id="g2gCbQAAAANELTVoA2IAAAW+YgAMmKxiAAnx/A==" max="300" resume="true"/>
After some chatting with other user, when i send following Stream resumption request :
<resume xmlns='urn:xmpp:sm:3'
h='0'
previd='g2gCbQAAAANELTVoA2IAAAW+YgAMmKxiAAnx/A=='/>
I got the following error:
<failed xmlns="urn:xmpp:sm:3"><unexpected-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></failed>
I have tried all the ways like disconnect the network, kill application and offline the user. But stream resumption is not working.
I am not getting the problem, Please help me.
Second Case:
When i use following configuration in ejabberd.yml:
listen:
port: 5222
module: ejabberd_c2s
resend_on_timeout: if_offline
stream_management: true
And start chatting after enables stream management. Then for the case of network disconnect and application kill, My all messages are storing in the offline queue (if i am not able to reconnect within 300 sec). In this process no one message is lost.
But my problem is this process is work only for mobile (ejabberd_c2s module). Web or Bosh is not supporting the stream management (ejabberd_http module). How can i use stream management for Bosh or web?

Android App continous receiving data via USB

I'm developing an Android App which i want to communicate with a device connected via USB. This device is delivering data all the time. These data are visible with a programm on the android linux shell.
My goal is to see those data in my App and after that deliver them via a Service to other Apps.
So my question is: Can i "open" a connection from my Android App to the USB-Port so im continuesly receiveing the data in my app, which are sent by the usb-device? And if yes, how would the code look like?
*Edit
Thank you for your answers, the app itself doesn't run on the commandline any more. So its no executable anymore but a shared library getting load by my android app.
It did before, but i want to be able to initiate the connection using NDK methods in my App to be able to see the data in my App itself. So I've tried to see if a connection is allready open.
I've added some functions to my code, so i can see if the usb-connection is open and i have the permission to that usb device.
UsbManager.hasPermission(device)
returns true, because I'm using an itent filter.
UsbManager.openDevice(device)
returns an UsbDeviceConnection, so i seem to have the access to use that device.
What im not capable of so far is receiving either iniciating the bus connection to by usb-device and of course either getting data input of that device.
Since my native code allready has a while(true)-method which is only using callbacks to send data to my app when actually data getting sent trough my usb-device i want to keep the work done in my c-code.
The only job my app should do is open the bus-connection once and after that be ready for callback from the c-code.
Is that possible?
If you have the app that runs on the command line, you can actually run a command line from within your app. Take a look at the Process class and the ProcessBuilder docs for full details. The example given is below
To run /system/bin/ping to ping android.com:
Process process = new ProcessBuilder()
.command("/system/bin/ping", "android.com")
.redirectErrorStream(true)
.start();
try {
InputStream in = process.getInputStream();
OutputStream out = process.getOutputStream();
readStream(in);
finally {
process.destroy();
}
}

Airplay in android device

I want to build an android application in which the android device work as airplay server (receiver) and iOS device as a client(sender). I have followed this link . But here you have to first register to the port to appear as a airplay option on iOS device from the command line using :
mDNS -R MyAirplayService _airplay._tcp local 22555
When i run this java code I can see airplay icon on my iOS device . But how it can be don in android device ? Is there any open source code or library to do this ?
That code is basically registering an airplay tcp service in the local network, so that any other iOS device on the same local network can discover this airplay service, and therefore display the airplay icon as an option.
In iOS, this can be done using the Bonjour/NSNetService. Please refer to the Apple's official tutorial.
NSNetService *service;
service = [[NSNetService alloc] initWithDomain:#""// 1
type:#"_airplay._tcp"
//this will show up as the airplay name
name:#"myiOSAirplayServer"
port:port];
if(service)
{
[service setDelegate:delegateObject];// 2
[service publish];// 3
}
else
{
NSLog(#"An error occurred initializing the NSNetService object.");
}
In Android, this can be done using Network Service Discovery, and the official example is here:
public void registerService(int port) {
NsdServiceInfo serviceInfo = new NsdServiceInfo();
//this will show up as the airplay name
serviceInfo.setServiceName("myAndroidAirplayServer");
serviceInfo.setServiceType("_airplay._tcp.");
serviceInfo.setPort(port);
mNsdManager = Context.getSystemService(Context.NSD_SERVICE);
mNsdManager.registerService(
serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);
}
However, doing so just registers the service in local network, and gives you an icon in the iOS device. To do the real airplay server/mirroring service, you need to do a lot more. If you want to know that, please check my iOS app that works as an Airplay mirroring server, https://www.youtube.com/watch?v=0d6ggJMypIk. There is also an open source project that is written in python, called PyOpenAirMirror.
If I'm not mistaken, Airplay is an Apple-only API. I have tried getting it to be recognizable on android and I was largely unsuccessful. You may want to consider another mode of transmission for the streaming audio.
I would look at Erica Sadun's utilities. I may be mistaken, but I think they are open source. She has written a server, player/transmitter etc. for AirPlay.
http://ericasadun.com/category/airplayer/

How to make socket connection from Android Emulator to another pc which is on the same lan

I am very new to Android. Our lan is working in class C IP (192.168.1.x series).
I need to establish socket connection between android emulator(Server) and java eclipse (eclipse-java-juno-SR1) which is acting like a client. As I got a information from "http://developer.android.com" website every Android emulator having 10.0.2.15 (Class A IP) by default. But our LAN is working in Class C.
"PC-1" which is using for Android Emulator is having 192.168.1.50 IP, and
the another one "PC-2" which is using for Eclipse-Java is having 192.168.1.55.
This is the setup which I have.
My work is, When I send a string command (through socket) from Android emulator(runing on PC-1) to Java program(runing on PC-2) then that Java program should send continuous jpg photo to Android emulator through socket.
I tried lot but when I try to work with sockets installed apk application is closing by this error: "Unfortunately, Activity name> is closing"
Please help me out in this...
Thanks in advance :)
Does your Application have the
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
in your Manifest - File ?
You can either insert the above line into the manifest xml,
or you can go to "permissions" add "uses permission" and then add the "Internet" one.
My Emulator has no problems opening a Webview to the internet with this permission,
and I can even access my router in my network through the browser in the emulator, which is on some 192.168... address.
Kind Regards and a Happy New Year,
karlheinz

Categories

Resources