1 year ago
#153391
Require_Assistance
webRTC connection working when connecting to webpage hosted locally, but not when hosted on a server
I am attempting to create a webRTC connection from a python app to a web service using aiortc on python side, and express js on the web service side. When hosting the web service on localhost I have no problems, however when I host it on a server I am unable. I can still access the web page just fine when hosted online, I just get the following very generic exception when I attempt to make a webRTC connection:
socketio.exceptions.ConnectionError: Connection refused by the server
.
Here is what I think is the relevant part of the python code:
import asyncio
import dataclasses
import os
import socketio
from pathlib import Path
from aiortc import RTCPeerConnection, RTCSessionDescription
from data_streams.StreamingTrack import StreamingTrack
# Socket.io details
NODEJS_URL = 'something.something.nl'
NODEJS_PORT = '4000'
ROOT = os.path.dirname(__file__)
CLASSROOM_ID = "defaultClassroom"
sio = socketio.AsyncClient()
await sio.connect("http://" + NODEJS_URL + ":" + NODEJS_PORT)
And here is what I believe is the relevant js code:
const indexRouter = require('./routes/index');
const usersRouter = require('./routes/users');
const app = express();
app.options('*', cors());
app.set('port', (process.env.PORT || 8080));
// initiating the socket server
const port = 4000;
const server = http.createServer(app);
const io = require('socket.io')(server);
app.use(express.static(__dirname + '/public'));
io.sockets.on('error', (e) => console.log(e));
io.sockets.on('connect_error', (err) => {
console.log(`connect_error due to ${err.message}`);
});
If any additional code is needed I can provide it.
The firewalls have been disabled so I don't think that is the issue, I would greatly appreciate any suggestions as to why I am unable to connect.
express
socket.io
webrtc
aiortc
0 Answers
Your Answer