Bug #1363

Mozilla + IPv6 + WebSockets = not working

Added by Anonymous 10 months ago. Updated 3 months ago.

Status:ClosedStart date:07/23/2012
Priority:NormalDue date:
Assignee:Koen Deforche% Done:

0%

Category:-
Target version:3.3.0

Description

Websockets don't function in Firefox 13.0.1 whenever I use an IPv6 address. They work in Chrome.

I'm using ::1 as the listening address.

Example:

#include <Wt/WApplication>
#include <Wt/WPushButton>

class Application: public Wt::WApplication
{
public:
    Application(const Wt::WEnvironment& env) :
            Wt::WApplication(env),
            flipflop(false)
    {
        this->button = new Wt::WPushButton("Pink", root());
        this->button->clicked().connect(this, &Application::eventHandler);
    }

    void eventHandler()
    {
        if ((this->flipflop = !this->flipflop))
            this->button->setText("Panther");
        else
            this->button->setText("Pink");
    }

private:
    bool flipflop;
    Wt::WPushButton *button;
};

Wt::WApplication *createApplication(const Wt::WEnvironment& env)
{
    return new Application(env);
}

int main(int argc, char **argv)
{
    return Wt::WRun(argc, argv, &createApplication);
}

Steps to Test:
1. Enable WebSockets in the wt_config.xml file.
2. Start the server listening on an IPv6 address.
3. Load page in Firefox.
4. Click the button.

Result:
Clicking the button doesn't do anything.

Expected Result:
The button's text toggles between "Pink" and "Panther."

Wt.1363.patch Magnifier (5.03 KB) Kevin Robertson, 07/28/2012 04:23 am

History

#1 Updated by Kevin Robertson 10 months ago

I filed this bug without being logged into redmine. I'm sticking this comment in here so that you can direct a question to me.

#2 Updated by Wim Dumon 10 months ago

Kevin,

Just made a little test: Chrome does switch to a WebSockets connection with an IPv6 Wt. FF doesn't even request to set up a websockets connection.

Before diving into this: this may be a bug in FF; do you know if FF can connect with other WebSockets implementations when using IPv6?

Wim.

#3 Updated by Kevin Robertson 10 months ago

The issue arises whenever the URI is built using location.hostname. I don't know if the spec is clear on this and browsers implement it differently.

FF:
location.hostname = "::1"

Chrome:
location.hostname = "[::1]"

A cross-browser solution has to be formulated. location.host will return [address]:port and can be used instead of catting the hostname and port separately. That needs tested on all of the supported browsers though.

References:
https://www.w3.org/Bugs/Public/show_bug.cgi?id=11587
https://developer.mozilla.org/en/window.location

#4 Updated by Kevin Robertson 10 months ago

Patch.

#5 Updated by Koen Deforche 4 months ago

  • Status changed from New to Resolved
  • Assignee set to Koen Deforche
  • Target version set to 3.3.0

Hey Kevin,

Thanks. location.host is indeed the better field in location !

Regards,
koen

#6 Updated by Koen Deforche 3 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF