breautek commented on issue #1124:
URL: 
https://github.com/apache/cordova-android/issues/1124#issuecomment-728911110


   These are the restricted ports, and why they are restricted. 
   
   
https://source.chromium.org/chromium/chromium/src/+/master:net/base/port_util.cc;l=22-91;drc=f50df03b5c021e63d80ecf09ea452fa9976071ea;bpv=1;bpt=0
   
   Basically these are known ports used by OS programs or other common 
software. Port 6000 is used by X11. While I don't think this matters for 
Android applications... afaik there is no way to explicitly allow these ports 
on the android webview. The chrome executable offers command line flags to do 
this, but I don't think there are an equivalent for the android webview. Quick 
google searches yields me no useful results. Browsing the chromium codebase for 
[SetExplicitlyAllowedPorts](https://source.chromium.org/chromium/chromium/src/+/master:net/base/port_util.cc;l=145;drc=f50df03b5c021e63d80ecf09ea452fa9976071ea;bpv=1;bpt=1)
 usages shows me the only time this method is called is via switches.
   
   I also found this [google 
discussion](https://groups.google.com/a/chromium.org/g/android-webview-dev/c/tikrYY4Lujw/m/Sy3D0Ik0RzoJ)
 that shows that it's not possible to use command line switches from the 
factory android webview. Switches are only enabled for debug builds of the 
android webview, which means it isn't possible for us to open up restricted 
ports. For this reason I'll be closing this issue.
   
   Obviously the simplest workaround is to simply not use a restricted port... 
but if you truly need to use port 6000 for whatever reason, I'll list some 
potential workarounds you can try:
   
   - Use a reverse proxy -- so that your web application communicates with a 
server listening on a non-restricted port, which then passes the connection 
onto your server using the restricted port. Most common web servers has some 
level of support of proxy passing the connection to another server.
   - Move all network logic outside of a webview by using a native http 
implementation. This does have a caveat that would make it difficult for you to 
use `<img>` tags or other media assets.
   
   If either of these workarounds are not sufficient for your use case. Then 
Cordova may not be a fit for you. You can try opening up dialog with the 
Chromium team to see if command line flags such as allowing restricted ports 
can be exposed so android app developers can utilise them in their apps. 
They'll usually entertain an idea if you can justify a strong reason why you 
must use a restricted port.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to