Skip to content

Import of net package causes os.Open syscall in net.maxListenerBacklog #8

Closed
@nwidger

Description

@nwidger

I just ran into an issue using the latest versions of github.com/gopherjs/gopherjs and github.com/gopherjs/websocket wihch seems to be caused by websocket pulling in the stdlib net package. net has a global variable var listenerBacklog = maxListenerBacklog() in net/net.go which gets initialized during package initialization. In the browser at runtime this initialization causes a call to os.Open("/proc/sys/net/core/somaxconn") which triggers the following error on the JS console:

warning: system calls not available, see https://github.com/gopherjs/gopherjs/blob/master/doc/syscalls.md

The solution that worked for me was to add the following stub to github.com/gopherjs/gopherjs/compiler/natives/net/net.go:

func maxListenerBacklog() int {
    return 0x80
}

where 0x80 is the value of syscall.SOMAXCONN for Linux. I'm using Go 1.4.1 on linux_amd64.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions