New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Operation not permitted" when connecting Lambda to IPv6 addresses #42

Closed
luciano-fiandesio opened this Issue Mar 5, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@luciano-fiandesio
Copy link

luciano-fiandesio commented Mar 5, 2018

When launching the Lambda, I get the following error:

{
  "stackTrace": [
    [
      "/var/task/handler.py",
      22,
      "lambda_handler",
      "return sqa.handle(event, context)"
    ],
    [
      "/var/task/squeezealexa/main.py",
      65,
      "handle",
      "return super(SqueezeAlexa, self).handle(event, context)"
    ],
    [
      "/var/task/squeezealexa/alexa/handlers.py",
      49,
      "handle",
      "return self.on_intent(request, session)"
    ],
    [
      "/var/task/squeezealexa/main.py",
      106,
      "on_intent",
      "pid = self.player_id_from(intent)"
    ],
    [
      "/var/task/squeezealexa/main.py",
      339,
      "player_id_from",
      "srv = self.get_server()"
    ],
    [
      "/var/task/squeezealexa/main.py",
      92,
      "get_server",
      "verify_hostname=VERIFY_SERVER_HOSTNAME)"
    ],
    [
      "/var/task/squeezealexa/ssl_wrap.py",
      61,
      "__init__",
      "self._ssl_sock = context.wrap_socket(socket.socket(socket.AF_INET6, socket.SOCK_STREAM, 0),"
    ],
    [
      "/usr/lib64/python2.7/socket.py",
      191,
      "__init__",
      "_sock = _realsocket(family, type, proto)"
    ]
  ],
  "errorType": "error",
  "errorMessage": "[Errno 1] Operation not permitted"
}

Please, note that I had to slightly modify the code to support IPv6 (my internet provider does not support port forwarding on IPv4...).

This is basically the line I have changed:

context.wrap_socket(socket.socket(socket.AF_INET6, socket.SOCK_STREAM, 0)

Any idea if this error may be related to my change or to the high port number I'm connecting to?

@declension

This comment has been minimized.

Copy link
Owner

declension commented Mar 5, 2018

Hmm, weird. But I haven't tried IPv6

Any idea if this error may be related to my change or to the high port number I'm connecting to?

How high? Though really it's only if it's low (<1024) I'd expect permissions problems; so maybe it's IPv6 then.

Do the tests pass? Perhaps try writing a new test that first creates the socket with socket.socket(socket.AF_INET6) and then wraps it, and debug to see what the errors are. Unless of course this always works locally and never on AWS... but that would be useful to know too.

@luciano-fiandesio

This comment has been minimized.

Copy link
Author

luciano-fiandesio commented Mar 5, 2018

Yes, the local_test.sh script works. It looks like AWS Lambda does not really support IPv6, but I would have expected another error, see this thread: https://forums.aws.amazon.com/thread.jspa?messageID=771807&#771807

@declension

This comment has been minimized.

Copy link
Owner

declension commented Mar 6, 2018

Yes, but I fear this seems to be the case according to this SO post too.

Looks like EC2 in VPCs can do IPv6 though, so worst case you could host the Python code on this (with a minimal wrapper, or maybe Serverless AWS or something), but that's a costly way round I guess

@declension declension changed the title "Operation not Pemitted" when launching the Lambda "Operation not Pemitted" when connecting Lambda to IPv6 addresses Mar 6, 2018

@declension declension changed the title "Operation not Pemitted" when connecting Lambda to IPv6 addresses "Operation not permitted" when connecting Lambda to IPv6 addresses Mar 6, 2018

@luciano-fiandesio

This comment has been minimized.

Copy link
Author

luciano-fiandesio commented Mar 6, 2018

Yeah, I will experiment with Serverless. Thanks for following up, I guess you can close the issue?

@declension declension closed this Mar 7, 2018

@declension

This comment has been minimized.

Copy link
Owner

declension commented Apr 15, 2018

See also now #50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment