Home/Support/Support Forum/Intermittent bind failure
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Intermittent bind failure

0 votes
I'm getting a bind error quite frequently on the ConnectPortX2 when executing the following code snippet

[pre]self.socket = socket(AF_ZIGBEE, SOCK_DGRAM, ZBS_PROT_TRANSPORT)
self.socket.bind(("", 0xe8, 0, 0))


#> python monitor.py
Traceback (most recent call last):
File "<string>", line 474, in ?
File "<string>", line 262, in __init__
File "<string>", line 1, in bind
socket.error: (22, 'Invalid argument')

I'm confident that nothing else is running, for example, here's the CLI 'who' output immediately after getting the above bind error:

#> who

ID From To Protocol Sessions

1 local shell telnet

Bizarrely, if I run the program 2 or 3 times in a row, it will frequently work fine after initially throwing the socket error.

Any ideas? This is preventing my code from starting reliably in "run on boot" mode (currently deactivated).
asked Oct 14, 2008 in Python by futnuh New to the Community (14 points)

Please log in or register to answer this question.

2 Answers

0 votes
The only way this error can be thrown is if the socket is already in use. Is it possible that the bind may be occurring twice in your code in some way?

Could you wrap your bind call in print statements to make sure?

Could you post a screen capture of the output of the "set python" command?

answered Oct 14, 2008 by jordanh Community Contributor (92 points)
0 votes
Actually, I believe it's possible for this error to occur if the network subsystem of the device has not fully initialized as well. If the system is still going through DHCP negotiation for example. This seems to match the fact that it blocks startup, but can still be run manually.

It's probably best to add a test try-except loop or an explicit startup delay for this call.
answered Oct 16, 2008 by DigiGuy42 Community Contributor (102 points)