Connecting to WS:// websocket (unsecure) in https site - javascript

I am trying to connect to a unsecure websocket from https site.
I got an error:
VM40:164 Mixed Content: The page at
'https://username.github.io/reponame/' was loaded over HTTPS, but
attempted to connect to the insecure WebSocket endpoint
'ws://192.168.2.152:9001/mqtt'. This request has been blocked; this
endpoint must be available over WSS.
Is there any way I can connect to unsecured WebSocket from https site?
If not, I want to test my website.
I can open http://localhost:port on PC, but I need to test from android browser too. But, I cannot access it from my android device in the same network using the http://IP:port.
Any suggestions will be appreciated.

Related

403 Forbidden error when open the next js site with http

When I want to open the Next JS website was deployed on IIS with http address, I get this error
Get http://...../_next/static/chunks/webpack-73760e2208a549db.js net::
ERR_ABORTED 403 (Forbidden)
But when I open the website with https I can open ir
The most common cause of 403 Forbidden Error is entering an incorrect URL, and many heavily protected web servers do not allow access to incorrect URLs. Do you only configure your website to be served securely over https? A page secured with SSL (or TLS) cannot be accessed over HTTP, because that means the page is no longer secured.
HTTPS and HTTP sites are actually different sites, they don't have to have the same content (although they often do, that is, a lot of HTTP sites these days just redirect you to the same place over HTTPS).
But it's best not to consciously serve a page of a HTTPS site over HTTP, and for the security of your site, please force the browser to always use HTTPS for the site, and not rely on 302 redirects to access the HTTPS version.

Javscript App is running on local Host but when it is deployed it not running properly

i have made a weather app using accuweather api ,which is working fine on the local host but when it is deployed it does not perform its functions
this is the error which am getting
Please check this blog post about mixed content:
What is Mixed Content?
When a user visits a page served over HTTP,
their connection is open for eavesdropping and man-in-the-middle
(MITM) attacks. When a user visits a page served over HTTPS, their
connection with the web server is authenticated and encrypted with SSL
and hence safeguarded from eavesdroppers and MITM attacks.
However, if an HTTPS page includes HTTP content, the HTTP portion can
be read or modified by attackers, even though the main page is served
over HTTPS. When an HTTPS page has HTTP content, we call that content
“mixed”. The webpage that the user is visiting is only partially
encrypted, since some of the content is retrieved unencrypted over
HTTP. The Mixed Content Blocker blocks certain HTTP requests on HTTPS
pages.
As I can see in your screenshot, the API is integrated over HTTP. You probably use HTTPS on your production server.

How can i fix Mixed Content issue in mqtt?

I need to connect to broker over websocket.
<script src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.min.js" type="text/javascript"></script>
<script>
// Create a client instance
client = new Paho.MQTT.Client("broker.hivemq.com", 8000, "" , "gokden");
// connect the client
client.connect({onSuccess:onConnect});
function onConnect(){
console.log("Connected!");
}
</script>
This is my connection code but i get this error:
mqttws31.min.js:36 Mixed Content: The page at 'karantinagunlugum.com' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://broker.hivemq.com:8000/'. This request has been blocked; this endpoint must be available over WSS.
You have 2 related but separate problems here.
broker.hivemq.com doesn't support Secure MQTT over Websockets (wss://) which is why the connection is being closed after 30 seconds when you try to connect
You are trying to connect from a page that was loaded over HTTPS. Pages loaded securely can not connect to insecure resources due to the secure origin policy in the browser, this is what the second error is telling you.
You have 2 choices
Turn off HTTPS for your site. This is not a good idea.
Setup your own broker that supports Secure MQTT over Websockets.
You shouldn't really be using broker.hivemq.com for anything other than basic testing and playing, if you want to do anything serious you should be either paying for a properly hosted broker or running your own.

Chrome: Mixed content issue for local IP address 192.168

I have a website which is all secure content on https and am using javascript sdk for local network printer which starts with 192.168.x.x
My printer is listening on that IP address with port 8008 (http)
When my application starts printing, the printer is initialized as soemthing like this
http://192.168.199.69:8008/socket.io/1/?t=1512574905603
Chrome is blocking this request and I am not able to print. Error msg as below.
How can I tell chrome that its a local URL and make it allow to request that URL?
epos-2.6.0.js:6 Mixed Content: The page at 'https://mywebsite/order-list.html' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://192.168.199.69:8008/socket.io/1/?t=1512574905603'. This request has been blocked; the content must be served over HTTPS.
Get a self signed certificate, upload to your service/server and there you go.
However the basic question of getting around http in a mixed content mode still remains or it won't be allowed..
Firefox adds an exception but chrome , im not sure
Self signed certificates are no longer accepted...
I really don't understant why mixed content blocks ip addresses of the local network, only localhost is allowed.
That means it is not possible to create a web app (a PWA for example) and communicate with small IOT devices (there are offline and just waiting commands through HTTP).

JsSip client with non secure websocket over https

I have been testing with jssip in firefox. I was able to load http://tryit.jssip.net. Although now this is redirected to secure channel over https://tryit.jssip.net. Which further does not allow ws:// connection.
Following is the jssip client error:
JsSIP:Transport connecting to WebSocket ws://a.b.c.d:p +2s
jssip.js:23543 Mixed Content: The page at 'https://tryit.jssip.net/' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://a.b.c.d:p/'. This request has been blocked; this endpoint must be available over WSS.W3CWebSocket # jssip.js:23543Transport.connect # jssip.js:19149(anonymous function) # jssip.js:20215
jssip.js:22841 JsSIP:ERROR:Transport error connecting to WebSocket ws://a.b.c.d:p: SecurityError: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS. +0ms
jssip.js:22666 JsSIP:UA transport ws://a.b.c.d:p failed | connection state set to 2 +1ms
Is there any way to use in non secure way or is it mandated? If so I searched hard but could not find anywhere on jssip release or version notes.
On an https webpage, only passive (like image or css) mixed (insecure) content will work .
So you must use wss if it's hosted on an https webpage.

Categories

Resources