Repository navigation
Open
Description
I doubt this is an issue with this particular library but I am unable to get the server/client up and running because of it so I thought I'd log it here. Basically, when running ./server.py I see the following stack trace:
ERROR:asyncio:Task exception was never retrieved
future: <Task finished coro=<Context.create_server_context() done, defined at /Users/matt/code/coap/aiocoap/aiocoap/protocol.py:530> exception=AttributeError("module 'socket' has no attribute 'IPV6_RECVPKTINFO'",)>
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
File "/Users/matt/code/coap/aiocoap/aiocoap/protocol.py", line 546, in create_server_context
self.transport_endpoints.append((yield from TransportEndpointUDP6.create_server_transport_endpoint(new_message_callback=self._dispatch_message, new_error_callback=self._dispatch_error, log=self.log, loop=loop, dump_to=dump_to, bind=bind)))
File "/Users/matt/code/coap/aiocoap/aiocoap/transports/udp6.py", line 126, in create_server_transport_endpoint
return (yield from cls._create_transport_endpoint(new_message_callback, new_error_callback, log, loop, dump_to, bind))
File "/Users/matt/code/coap/aiocoap/aiocoap/transports/udp6.py", line 100, in _create_transport_endpoint
sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_RECVPKTINFO, 1)
AttributeError: module 'socket' has no attribute 'IPV6_RECVPKTINFO'
Sure enough, I'm unable to see that socket option on any of my Python 3 installs (3.4, 3.5, 3.6). On a different Ubuntu machine the option is there. I just updated the Mac today and I'm wondering if possibly they got rid of some setting from the C socket implementation.
Currently running macOS 10.12.4. Any ideas of how to get that option back or a workaround?
Activity
chrysn commentedon Apr 11, 2017
mattdodge commentedon Apr 11, 2017
Confirmed on two coworker's machines, one running 10.12.3 and the other on 10.12.4, that it fails on both. I am able to get it to work on Linux machines though. Has anyone tested macOS support?
Looks like it's in the Apple source though unless I'm looking at the wrong spot? https://opensource.apple.com/source/xnu/xnu-1699.24.8/bsd/netinet6/in6.h
mattdodge commentedon Apr 11, 2017
Also just tried on macOS 10.11.6, same result, can't find
IPV6_RECVPKTINFO.chrysn commentedon Apr 11, 2017
mattdodge commentedon Apr 11, 2017
Replaced
socket.IPV6_RECVPKTINFOwith61inaiocoap/transports/udp6.py. Now server won't start and tests fail with an invalid argument error to setsockopt withIPV6_RECVERR. Looks like macOS doesn't like setting option 25, which is whatsocknumbers.IPV6_RECVERRis, to 1.chrysn commentedon Apr 11, 2017
If you just comment out the RECVERR line, do things get better? (And possibly also other setsockopt lines).
That loses reception of ICMP error messages, so requests to unavailable hosts or closed ports take longer to timeout, but that'd be fine for initial (it seems you are the first to try it) support on OSX.
[-]Can't find socket option IPV6_RECVPKTINFO[/-][+]macOS unsupported (no option IPV6_RECVPKTINFO)[/+]mattdodge commentedon Apr 11, 2017
Not really able to make it work reliably unfortunately. I can get the
server.pyto start successfully by commenting out the setsockopts for IPPROTO (v6 and non-v6). Upon sending messages though it starts spitting out additional errors, this time aroundsocket.MSG_ERRQUEUE. Replacing that value with0x2000(got it from linux machine) doesn't seem to work either. I get repeated stack traces like this:For reference, here's the diff of what I changed
Singhal-Vaibhav commentedon Jul 14, 2017
Is there any update on this issue? I get the same issue, running on OS X v10.10.5
chrysn commentedon Sep 12, 2017
The simple6 transport should give at least a working client implementation.
Could you try running
AIOCOAP_CLIENT_TRANSPORT=simple6 ./aiocoap-client coap://coap.me/or similar with current master? Server is not implemented there, but I think that clients using the simple6 transport should work now on OSX too, but can't test it myself.Firflei commentedon Mar 4, 2018
For me running the client (commit 43255ab) works without the AIOCOAP_CLIENT_TRANSPORT option on macOS High Sierra 10.13.3
Interestingly enough running the server from the Usage Examples results in the above error regarding the apparently missing socket option. Running the server.py from the repository (which - skimming the code - looks very similar) does give a different error (as described in #101):
Changing the file so that it explicitly binds to an address results in the error of this issue though:
chrysn commentedon Dec 23, 2018
I've forwarded this to the Python issue tracker as issue35569.
DanAbbruzzese commentedon Mar 24, 2020
@chrysn - Is this now resolved?
Does it require an updated python version? I am currently running on Python 3.7.4
chrysn commentedon Mar 24, 2020
yance-dev commentedon May 9, 2020
I got the same error run aiocoap on python(3.8.1)
chrysn commentedon May 18, 2020
(Note to self: run tests using https://github.com/kholia/OSX-KVM/blob/master/boot-macOS-NG.sh ?)
braelyn-ai commentedon Aug 9, 2020
Has this issue still not been resolved? I'm experiencing it on both mac and windows. No luck at all. I suppose I'll have to use a different CoAP library
chrysn commentedon Aug 9, 2020
marianhlavac commentedon Aug 10, 2020
@bboynton97 What version are you on? Updating to the latest version helped me with the problem.
iskep11 commentedon Oct 14, 2020
Greetings,
I am having this error too. I am on Windows 10 using the latest Visual Studio Code (if that matters at all).
Python version is 3.8.4.
barracuda156 commentedon May 28, 2023
Has any fallback been found for macOS versions without
IPV6_RECVPKTINFO?chrysn commentedon May 28, 2023
barracuda156 commentedon May 28, 2023
@chrysn Are those portable? I bumped into this problem with
ngtcp2: ngtcp2/ngtcp2#804chrysn commentedon May 29, 2023
The simple6 and simplesocketserver are portable, but they do without even PKTINFO -- they simply spawn individual sockets. (Actually, aiocoap by now has the infrastructure to use PKTINFO even on OSX by virtue of hardcoded numbers to fill in what has been missing up to 3.9, but it's not only PKTINFO that's missing -- see longer upcoming explanation).
chrysn commentedon May 29, 2023
The current status of OSX and Windows support, as far as I can tell it without access to either system, is as follows:
Without PKTINFO, the udp6 transport would violate the CoAP protocol without any local means of debugging, thus it fails hard when attempted to use it. (It would send acknowledgements to messages from a different IP address, which is an error).
Without RECVERR, ICMP errors are not propagated to the socket, so instead of getting an error about an unreachable peer immediately, aiocoap would be retransmitting until timeout. This is bad practice.
That transport has the downside of opening a socket per connection (as a client), still not getting ICMP errors (as a server), requiring a specific IP address to be bound to (as a server) and not sending requests from the same port as the server is running on (when using both roles) -- but it's portable.
I'd encourage users (especially on the server side) on non-Linux UNIX systems, to try out setting AIOCOAP_SERVER_TRANSPORT=oscore:tinydtls:tcpserver:tcpclient:tlsserver:tlsclient:ws:udp6 (or fewer of these depending on which you actually use, but with udp6 instead of the simple* ones) and report experiences here.
Apart from that, I'd encourage developers familiar with Windows to contribute to python/cpython#80398. To developers familiar with the network stacks of non-Linux systems: Do these platforms provide any equivalent of the RECVERR mechanism of Linux?
[-]macOS unsupported (no option IPV6_RECVPKTINFO)[/-][+]macOS not fully supported[/+]