Some background, just so you know what I am trying to achieve before someone suggests that what I want is not what I want: I am developing a Vue.js 3 service, with a little Python (Flask) backend. Both components run on (Ubuntu) WSL2 and Windows 10. Everything has worked fine referring to http://localhost:8080 (Vue) and http://localhost:5000 (Flask) respectively (URLs work out of the box from my Chrome on Windows without further configuration).
My problem is that I could also use exposing 8080 with the IP number on my LAN to test the UI I'm building with my phone (inspiration here). Trying to do this, in turn, lead me here and here).
All good? Not so much, because:
Ubuntu:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal
$ ip addr | grep eth0
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
inet 172.24.76.40/20 brd 172.24.79.255 scope global eth0
The Flask server works (here's Ubuntu, but same thing from the Windows Powershell)
$ curl http://172.24.76.40:5000
<html>
<head>
<title>Test file upload</title>
<style>
body {
:
But, sort of inexplicably to me:
$ curl http://172.24.76.40:8080
curl: (7) Failed to connect to 172.24.76.40 port 8080: Connection refused
yet:
$ curl http://localhost:8080
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="/favicon.ico">
Of course http://172.24.76.40:8080 won't be accessible from Chrome on Windows 10 either.
Flask (port 5000) is accessible from Chrome on Windows and even from my Android phone (with the Windows IP of course: http://192.168.1.156:5000 ) on the same Lan (that's after I went into the Windows Firewall to open the port and did this port forwarding in the powershell:
PS C:\WINDOWS\system32> netsh interface portproxy add v4tov4 listenport=5000 listenaddress=0.0.0.0 connectport=5000 connectaddress=172.24.76.40
Dear network wizards, am I going crazy? What am I missing?
Thank you
Ok, I found the solution, and believe me, this was a gotcha of major proportion, as the solution was to be found in a rather different place than I had expected.
As I had the backend and the front-end running on the same localhost, CORS had raised its ugly head and given me a hard time. I had addressed that issue with this approach some time back. Little did I know that this was also introducing such a nasty side effect that had gone unnoticed for quite a while (making the server at that IP appear unreachable!). In short, it was not a network issue, albeit it damn sure looked like one!
My solution was to change the vue.config.js file from this:
devServer: {
proxy: 'http://localhost:5000/',
host: 'localhost'
},
to this:
devServer: {
proxy: {
"/upload": {
target: "http://localhost:5000"
}
}
},
I am sure that React.js developers may find themselves in a similar situation. Now you know where to look at. Same goes for users of other frameworks.
Related
I have a Digital Ocean droplet running two Docker containers, one that is a Vue3 app which I'm having issues with, and a Django server that I'm not having issues with.
vue-cli-service serve --mode production --host 0.0.0.0 --public http://XXX.YYY.ZZZ.XXX:8080
If I go in Chrome and type www.websitename.com
This site can’t be reached websitename.com refused to connect.
If I go in Chrome and directly type the IP and the port I can see the website load. Is this a DNS resolution issue? I really don't think so, here's why:
If I go in Chrome and type http://websitename.com:8000/admin
I see a Django administration site. This means that I have no problem with Django, only with Vue3.
I tried setting --host 0.0.0.0, I tried adding --public with the website name and with the IP directly.
Also nmap seems to show everything working fine
nmap -F websitename.com <---- No issue with DNS resolution
Starting Nmap 7.80 ( https://nmap.org ) at 2022-07-26 20:14 PDT
Nmap scan report for XXX.YYYY.ZZZ.XXX <---- Correct IP
Host is up (0.090s latency).
Not shown: 92 closed ports
PORT STATE SERVICE
22/tcp open ssh
25/tcp filtered smtp
111/tcp filtered rpcbind
135/tcp filtered msrpc
139/tcp filtered netbios-ssn
445/tcp filtered microsoft-ds
8000/tcp open http-alt <---- Django
8080/tcp open http-proxy <---- Vue3
If you do not provide a port in Chrome - it will default to port 80. But your Vue3 Docker is running on port 8080. Therefore you have to either provide this port when you type the URL in Chrome - or you must run your Docker on port 80.
You are providing port 8000 for the Django administration site - do the same (with port 8080) for your Vue3 application.
I have an application that has video and sound communication.
I used Webrtc I created the connection like the following code
foundedPC.createOffer(function(desc) {
foundedPC.setLocalDescription(desc, function() {
console.log("Create offer" + callId);
hub.invoke("sendSignal", JSON.stringify({
"sdp": foundedPC.localDescription
}), callId);
});
}, function(error) {
console.log('Error creating session description: ' + error);
});
then I created the answer and return the answer packet
evrey thing works on the local system, I rent a stun server because I found the answer in this linkstack he said the problem is stun and turn server.
but it didn't work for me.
whenever I turn on my VPN and my client also turn on the VPN Webrtc work nicely.
I don't know how the vpn effect on webrtc connection
I am pretty sure the problem is still the lack of a TURN server. I would guess the configuration to access the rented STUN/TURN server was not right.
Maybe try something different, also a very cheap alternative, I use Digital Ocean and installed CoTurn as my STUN/TURN server on a Ubuntu droplet. You pay only $0.007 per hour for the droplet. If you don't use it anymore (I use it for testing at this moment) you just destroy the droplet and you don't pay anymore. If you make a snapshot of the droplet, you can easy reinstall the droplet when you want to use it again. Snapshots costs $0.05/GB/month.
Installing CoTurn on a Ubuntu machine is very easy:
Select Ubuntu 16.04.3 x64 or 17.10 x64 when creating a droplet.
Installing:
sudo apt-get update
sudo apt-get install coturn
Next, edit sudo vi /etc/turnserver.conf and change the following options:
fingerprint
lt-cred-mech
realm=ip-address-public-droplet
listening-ip=ip-address-public-droplet
user=test:test
Next, edit sudo vi /etc/default/coturn and add the following options:
TURNSERVER_ENABLED=1
Create or modify service package for our program:
sudo vi /etc/systemd/system/coturn.service
Then paste the content of this.
After modifying a unit file, you should reload the systemd process itself to pick up your changes:
sudo systemctl daemon-reload
Now the installation is complete, we'll start the Coturn daemon:
sudo systemctl start coturn
Since systemctl doesn't provide output, we'll check the status to verify that the service has started properly:
sudo systemctl status coturn
Now that we've manually started the daemon and verified that it’s running, we'll ensure that it restarts automatically at boot:
sudo systemctl enable coturn
In your app you need something like:
var pcConfig = {
'iceServers': [
{'urls': 'stun:ip-address-public-droplet:5349'},
{'urls': 'turn:ip-address-public-droplet:5349', 'username': 'test', 'credential': 'test'}
]
};
You can force your app using TURN by:
var pcConfig = {
iceTransportPolicy: "relay",
'iceServers': [
{'urls': 'stun:ip-address-public-droplet:5349'},
{'urls': 'turn:ip-address-public-droplet:5349', 'username': 'test', 'credential': 'test'}
]
};
When the connection is established you can check if TURN server (relay) is used by going through the stats page.
Chrome address bar: chrome://webrtc-internals or Firefox address bar: about:webrtc.
Look for the 'bold' header: Conn-audio-1-0 (googCandidatePair)
Use Nothing: googRemoteCandidateType: local
Use of STUN: googRemoteCandidateType: stun
Use of TURN: googRemoteCandidateType: relay
STUN might not be enough and you may need to use TURN as well.
Free servers are great, but they don't cut it for WebRTC - no one exposes his TURN server for others to use as that costs money (a more detailed explanation here).
You will need to install and run your own TURN server or use a third party service such as XirSys or Twilio NAT Traversal.
I am new to node.js and am trying to get into the hang of actually using it. I am very familiar with JavaScript so the language itself is self-explanatory but the use of Node.js is quite different from the browser implementation.
I have my own remote virtual server and have installed Node and the Package Manager and everything works as expected. I am not exactly a server extraordinaire and have limited experience with the Terminal and Apache Configurations.
I can run my server using:
nodejs index.js
Which gives me: listening on *:3300 as expected.
I can then access my localhost from the terminal using: curl http://localhost:3300/ which gives me the response I expect.
Given that the website that links to my server is https://example.com, how do I allow this link to access: http://localhost:3300/ so that I can actually use my node server in production? For example, http://localhost:3300/ runs a Socket Server that I would like to use using Socket.io on https://example.com/chat.html with the JavaScript:
var socket = io.connect('http://localhost:3300/', {transports: ['websocket'], upgrade: false});
Ok, this question has nothing to do with nodeJS.
localhost is a hostname that means this computer. it's equivalent to 127.0.0.1 or whatever IP address you can refer to your computer.
After the double colon (:) you enter the port number.
So if you want to make an HTTP call to a web-server running on your server, you have to know what is the IP address of your server, or the domain name, and then you call it with the port number where the server is running.
For Instance, you would call https://example.com:3300/chat.html to make an HTTP call to a server running on example.com with port 3300.
Keep in mind, that you have to make sure with your firewall configuration, that the specific port is open for incoming HTTP requests.
We are trying to use RESTCOMM OLYMPUS by making few customizations as part of our application. The main customization is that we have deployed OLYMPUS war on our Apache TOmcat web server and the OUTBOUND PROXY is properly pointed to the same server where RESTCOMM is running.
So far all is good, but recently we got the issue that "getUserMedia()" deprecation issue because of insecure origin issue by chromium fix.
So, it means we need to use HTTPS and WSS. I can see that just around 7 days back OLYMPUS code has been updated on GITHUB to use WSS if HTTPS has been used in browser location bar.
So first we have installed self signed CERT and enabled SLL config on TOMCAT so that our customized OLYMPUS UI is accessed via https from Tomcat. And then we used WSS protocol to connect to OUTBOUND PROXY. Bt we got the below error
"WebSocket connection to 'wss:/:5082/' failed: Error in connection establishment: net::ERR_TIMED_OUT
WSMessageChannel:createWebSocket(): websocket connection has failed:[object Event]"
Then we thought that in addition to TOMCAT ( where WAR is deployed) we need to install self singed cert and SSL config on RESTCOMM as well. So we did it by following http://docs.telestax.com/restcomm-enable-https-secure-connector-on-jboss-as-7-or-eap-6/ and also we have used WSS protocol.
But this time also we got the error but with a different error code though
"WebSocket connection to 'wss:/:5083/' failed: Error in connection establishment: net::ERR_CONNECTION_CLOSED
WSMessageChannel:createWebSocket(): websocket connection has failed:[object Event]"
Can i request the forums to explain if we are missing any thin here?
Thanks in advance
I would suggest to use the mobicents RestComm docker image instead of using the zip bundle, because for docker image all settings are handled automatically and https/wss should work out of the box. Here are some quick steps to get you started:
Install docker in your Ubuntu if not already there
Download RestComm docker image:
$ docker pull mobicents/restcomm:latest
Start docker image:
$ docker run -e SECURE="true" -e SSL_MODE="allowall" -e USE_STANDARD_PORTS="true" -e VOICERSS_KEY="VOICERSS_KEY_HERE" --name=restcomm -d -p 80:80 -p 443:443 -p 9990:9990 -p 5060:5060 -p 5061:5061 -p 5062:5062 -p 5063:5063 -p 5060:5060/udp -p 65000-65535:65000-65535/udp mobicents/restcomm:latest
Now you should be able to reach your RestComm instance Admin UI at:
https://<host ip address>/
Make sure that you don't have any servers running in your host at the ports used by the docker container above, or you'll have to use different ports (please refer to the docker hub page for such options)
Best regards,
Antonis Tsakiridis
Trying to put together a project running an express server and gulp, browsersync, nodemon and mongodb. However I seem to be an Error: listen EADDRINUSE when I add browsersync. Any idea how to do this?
This means you already have a program listening on the port you are trying to use. What port are you running your application on? Is it 3000? If so, stop all other programs you have running that are using that port and you'll be good to go.
Are you defining in the browser-sync configuration the port to use?
In that case, the port needs to be something different from the one (if any) defined from the proxy. This works in my setup:
gulp.task('browser-sync', ['nodemon'], function() {
browserSync.init(null, {
proxy: "http://localhost:3000",
browser: ['google chrome'],
port: 4000
});
});
As reference, the full gulpfile.js (that uses nodemon and browsersync) is here.