I have a Firefox extension which creates a websocket client and sends a message to the server. The extension and the server are on the same system. If I use local
, the websocket does connect to the server. If the IP address of the interface is used, the client cannot connect to the server. As proof I can connect with the IP address, I have other client and server applications which connect with each other through raw sockets with the IP address and messages are received by the server.
I use secured websockets. I added the certificate to Firefox's certificate manager.
I am not sure if the problem is that I am formatting the address incorrectly or that there are missing permissions in the extension manifest.
manifest.json:
{
"description": "weblogging app",
"manifest_version": 2,
"name": "weblogger",
"version": "1.0",
"browser_specific_settings": {
"gecko": {
"id": "browser_logger@example.org",
"strict_min_version": "50.0"
}
},
"background": {
"scripts": ["background.js"]
},
"permissions": []
}
background.js:
var websocketArguments = 'wss://192.168.1.123:9501';
var webSocket;
createWebsocket();
function onError(error)
{
console.log(`Error: ${error}`);
}
function createWebsocket()
{
webSocket = new WebSocket(websocketArguments);
webSocket.onerror = onWebSocketError;
webSocket.onopen = onWebSocketOpen;
}
function onWebSocketError(event)
{
console.log("WebSocket error observed:", event);
};
function onWebSocketOpen(event)
{
console.log("WebSocket open: ", webSocket.readyState);
webSocket.send("hello");
};