Skip to content
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

TCP_MAXSEG cannot be set using SOL_TCP #130

Open
drewkilz opened this issue Jan 4, 2017 · 5 comments
Open

TCP_MAXSEG cannot be set using SOL_TCP #130

drewkilz opened this issue Jan 4, 2017 · 5 comments

Comments

@drewkilz
Copy link

drewkilz commented Jan 4, 2017

I was testing utilizing this package on a Windows 7 Enterprise N, 64-bit machine and ran into the error listed below. The problem seems to be with attempting to set the TCP_MAXSEG socket option utilizing SOL_TCP. However, if you simply change this to using socket.SOL_SOCKET it can be set without a problem. This if my first foray into sockets, so I am not sure that is the "correct" solution.

Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 5.0.3\helpers\pydev\pydevd.py", line 2407, in
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 5.0.3\helpers\pydev\pydevd.py", line 1798, in run
launch(file, globals, locals) # execute the script
File "C:/SLS/Dropbox/ABP/Code/arraypy/arraybiopharma/messagequeue/init.py", line 95, in
mq = MessageQueue()
File "C:/SLS/Dropbox/ABP/Code/arraypy/arraybiopharma/messagequeue/init.py", line 32, in init
self.connection.connect()
File "C:\Python27\lib\site-packages\amqp-2.1.4-py2.7.egg\amqp\connection.py", line 294, in connect
self.transport.connect()
File "C:\Python27\lib\site-packages\amqp-2.1.4-py2.7.egg\amqp\transport.py", line 128, in connect
self.socket_settings, self.read_timeout, self.write_timeout,
File "C:\Python27\lib\site-packages\amqp-2.1.4-py2.7.egg\amqp\transport.py", line 180, in _init_socket
self._set_socket_options(socket_settings)
File "C:\Python27\lib\site-packages\amqp-2.1.4-py2.7.egg\amqp\transport.py", line 210, in _set_socket_options
self.sock.setsockopt(SOL_TCP, opt, val)
File "C:\Python27\lib\socket.py", line 222, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 10042] An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call
findFrame: frame not found.
Looking for thread_id:pid14784_seq2, frame_id:54157024
Current thread_id:pid14784_seq2, available frames:
41174616 - 41163264 - 54227504 - 51494640 - 41161696
41173392 -

findFrame: frame not found.
Looking for thread_id:pid14784_seq2, frame_id:54157024
Current     thread_id:pid14784_seq2, available frames:
41174616  -  41163264  -  54227504  -  51494640  -  41161696

41173392 -

@abhijeetbhanjadeo
Copy link

Ran into this issue while using nameko which has dependencies for kombu which in-turn has dependencies for amqp.

Errors seen:
[WinError 10042] An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call
For:
File "C:\Program Files\Anaconda3\envs\test\lib\site-packages\amqp\transport.py", line 204, in _set_socket_options self.sock.setsockopt(SOL_TCP, opt, val)

Temporarily resolved by downgrading the version of amqp to 2.1.3
Steps:

  1. Uninstall amqp using pip uninstall amqp
  2. Install amqp using pip install -Iv amqp==2.1.3 . 2.1.3 version

Environment Used:
OS Name: Microsoft Windows 10 Enterprise
OS Version: 10.0.10586 N/A Build 10586
OS Manufacturer: Microsoft Corporation
OS Build Type: Multiprocessor Free
System Type: x64-based PC
BIOS Version: LENOVO N11ET39W (1.15 ), 26/7/2016

@thedrow
Copy link
Member

thedrow commented Oct 28, 2017

Can any of you confirm this is still a problem with master?

@sorab2142
Copy link

@thedrow Can confirm this still happens and downgrading to 2.1.3 solved the issue for me.

@matusvalo
Copy link
Member

Unfortunately, I am not able to replicate it:

>python.exe
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import amqp
>>> c = amqp.Connection('localhost')
>>> c.connect()
>>>

Are there any steps how to reproduce this issue?

@snemes
Copy link

snemes commented Oct 2, 2024

I was hit by this exact same issue too. The main symptom was that Celery started throwing connection errors:

[2024-10-01 15:27:29,428: ERROR/MainProcess] consumer: Cannot connect to amqp://<redacted>:**@<redacted>:5672//: [Errno 22] Invalid argument.
Trying again in 2.00 seconds... (1/None)

I tried to locate the source of the error, and it seems to be this line:

self.sock.setsockopt(SOL_TCP, opt, val)

The code retrieves the TCP socket defaults via _get_tcp_socket_defaults(self.sock), and the default settings apparently include TCP_MAXSEG (2) with the value 32768 on my system. However when it tries to set that value it returns an error (maybe due to lack of permissions as I'm running this with an ordinary, non-root user - I'm using Debian bookworm as an OS).

Maybe just adding an exception handling block around setsockopt() would work as a workaround, as failure to set the socket options is probably a graceful error that shouldn't keep AMQP from working.

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

No branches or pull requests

7 participants