为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

How to stop Firefox from changing the URL protocol from wss to https when sending a websocket upgrade HTTP request?

  • 4 个回答
  • 1 人有此问题
  • 1 次查看
  • 最后回复者为 dariour

more options

We are working on an express/react application which is using websockets through https to fetch the data and display it on the front end. The app is working as designed on every browser except Firefox. It turns out that Firefox resolves the Request URL to "https://example.url" instead of sending "wss://example.url", which is the default behavior that works on every other broser. This in turn causes problems on the server during load balancing, and the server simply returns a 404 http error code.

I have already tried editing the about:config page in firefox regarding websockets and urlbars, to no avail. (although that would not count as a solution, since we cannot force our clients to do the same)

Is there a way to disable said behavior on Firefox or force it to use wss?

We are working on an express/react application which is using websockets through https to fetch the data and display it on the front end. The app is working as designed on every browser except Firefox. It turns out that Firefox resolves the Request URL to "https://example.url" instead of sending "wss://example.url", which is the default behavior that works on every other broser. This in turn causes problems on the server during load balancing, and the server simply returns a 404 http error code. I have already tried editing the about:config page in firefox regarding websockets and urlbars, to no avail. (although that would not count as a solution, since we cannot force our clients to do the same) Is there a way to disable said behavior on Firefox or force it to use wss?

所有回复 (4)

more options

I see you posted this question on Stackoverflow too.

Does looking at this MDN article and this bug help?

more options

No unfortunately. The issue is similar but not the same. Our problem is that even when we hardcode the URL scheme (the whole URL, actually, there is only one) in our application to "wss://", Firefox automatically converts it to "https://", which is unexpected behavior and it causes app-breaking errors. Other browsers don't do this. Instructions on how to mitigate such behavior, or at least an explanation as to why (and how) Firefox does this would be extremely helpful.

more options

It’s not entirely my cup of tea, but are you using a self-signed certificate on localhost, which is supposed to fail? More on that can be found this bug, this bug, this bug and this bug, possibly providing a workaround.

Additionally, could you define "resolve" in "It turns out that Firefox resolves the Request URL to "https://example.url" instead of sending "wss://example.url"? Does that include entering the wss URL on the address bar?

more options

On localhost we aren't using SSL at all. We are using regular http (and ws) for various reasons.

By "resolve" I mean the following: the web app provides the browser with a hard-coded url which looks like "wss://example.url". Firefox takes that url and changes it to "https://example.url" before sending the request to the server.

I have mentioned that we dont use SSL on localhost. It's important to notice that the same thing happens on localhost also, the only difference is that firefox takes the following url: "ws://example.url" and changes it to "http://example.url" before sending.

On localhost this works because there is no load balancer in the way (which is the point where our application breaks). You can think of it as a firewall that blocks traffic when it sees https in the URL but allows wss (a useful way of thinking about it, although not accurate).

I dont think you can check wss functionality through the address bar since it contains additional headers. (it just returns an error, nothing happens, not even the changing from wss to https)

This seems to be an issue with the way Firefox is inherently setup.