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

[Bug]: zmq.error.ZMQError: Can't assign requested address error trying NetGear+WebGear example #291

Closed
3 tasks done
iandol opened this issue Feb 19, 2022 · 6 comments · Fixed by #293, #295 or #321
Closed
3 tasks done
Assignees
Labels
BUG 🐛 Vidgear api's error, flaw or fault DOCS 📜 Issue/PR is related to vidgear docs. SOLVED 🏁 This issue/PR is resolved now. Goal Achieved!
Milestone

Comments

@iandol
Copy link
Contributor

iandol commented Feb 19, 2022

Brief Description

I have a Raspberry Pi400 (using latest 64bit Bullseye release) with a UVC USB3 camera attached. On the same local network I have a Macbook Pro that I want to use to connect to the RPi and display the camera output. Speaking to @abhiTronix on chat, he recommended the following code: https://abhitronix.github.io/vidgear/latest/help/netgear_ex/#using-netgear-with-webgear

However, the client code crashes when trying to set up ZMQ connection:

zmq.error.ZMQError: Can't assign requested address
RuntimeError: [NetGear:ERROR] :: Receive Mode failed to bind address: tcp://192.168.1.44:5454 and pattern: 1! Kindly recheck all parameters.

I've tested the ZMQ hello world test code and it works fine on the same machines. I also tested uvicorn to run a simple server and it works. I have reinstalled zmq (brew reinstall zmq) on the client machine, and using venv have reinstalled all pip packages from scratch. Python is V3.10.2 on the client and V3.9.2 on the server.

The code (slightly modified to fix a couple of errors I got from Python (no self, cannot return a value in async) and error logs are found at this gist:

https://gist.github.com/iandol/ebf722f75251bb9f5bc57ba967fd12ba

Acknowledgment

Environment

  • VidGear version: 0.25* Branch:
  • Python version: 3.10.2
  • PiP version: 22.0.3
  • Operating System and version: macOS 12.2.1

Expected Behavior

See the video from RPi in the Macbook browser.

Actual Behavior

client.py crashes

Steps to reproduce

(Write your steps here:)

  1. Clean 64bit bullseye OS, create a new venv on the RPi, install vidgear[core] and deps to run Netgear and CamGear. Add server.py taken from example code. Use IP taken from RPi.
  2. Create venv on macOS, install vidgear[asyncio] and any other Netgear and Webgear deps.
  3. Add client.py on macOS set up to correct IP of RPi.
  4. Run server.py on RPi and cleint.py on macOS.
@welcome
Copy link

welcome bot commented Feb 19, 2022

Thanks for opening this issue, a maintainer will get back to you shortly!

In the meantime:

  • Read our Issue Guidelines, and update your issue accordingly. Please note that your issue will be fixed much faster if you spend about half an hour preparing it, including the exact reproduction steps and a demo.
  • Go comprehensively through our dedicated FAQ & Troubleshooting section.
  • For any quick questions and typos, please refrain from opening an issue, as you can reach us on Gitter community channel.

@abhiTronix
Copy link
Owner

abhiTronix commented Feb 19, 2022

@iandol what's the local IP addresses on both mac and Rpi? Follow following instructions and paste the results here:

  • Open a Terminal app on each machine.
  • Type and run /sbin/ifconfig this will list your local IP address.
  • You can use cmd+a to select all, cmd+c to copy and it can be paste it here.

@abhiTronix abhiTronix added the MISSING : INFORMATION 🔍 Requested proper information/evidence about the Issue/PR in context. label Feb 19, 2022
@iandol
Copy link
Contributor Author

iandol commented Feb 19, 2022

My RPi is assigned 192.168.1.44 and my macbook is 192.168.1.38. I can ping 192.168.1.44 from the macbook OK, and as I said I tried to run the zmq hello world server/client, and I've also tried lazy pirate from the zmq docs using the same 192.168.1.44:5454 and it works fine; code here: https://gist.github.com/iandol/a0cd594d790230435d4f3d343830da9f

RPi:

❯ ifconfig              
eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether dc:a6:32:fd:fb:d1  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 50634  bytes 2534509 (2.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 50634  bytes 2534509 (2.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.44  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::6929:d8dd:27f8:3367  prefixlen 64  scopeid 0x20<link>
        ether dc:a6:32:fd:fb:d5  txqueuelen 1000  (Ethernet)
        RX packets 85726  bytes 27307320 (26.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 67060  bytes 37502674 (35.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

macbook:

gears on  main [!?⇡] via 🐍 v3.10.2 (vidgear) took 5s
❯ ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
	options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
	inet 127.0.0.1 netmask 0xff000000
	inet6 ::1 prefixlen 128
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
	nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether ac:bc:32:8c:08:39
	inet6 fe80::1cd9:3c9c:20ff:6cc2%en0 prefixlen 64 secured scopeid 0x4
	inet 192.168.1.38 netmask 0xffffff00 broadcast 192.168.1.255
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
en1: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
	options=460<TSO4,TSO6,CHANNEL_IO>
	ether 82:17:03:a6:48:00
	media: autoselect <full-duplex>
	status: inactive
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
	options=460<TSO4,TSO6,CHANNEL_IO>
	ether 82:17:03:a6:48:01
	media: autoselect <full-duplex>
	status: inactive
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=63<RXCSUM,TXCSUM,TSO4,TSO6>
	ether 82:17:03:a6:48:00
	Configuration:
		id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
		maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
		root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
		ipfilter disabled flags 0x0
	member: en1 flags=3<LEARNING,DISCOVER>
	        ifmaxaddr 0 port 5 priority 0 path cost 0
	member: en2 flags=3<LEARNING,DISCOVER>
	        ifmaxaddr 0 port 6 priority 0 path cost 0
	nd6 options=201<PERFORMNUD,DAD>
	media: <unknown type>
	status: inactive
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
	options=400<CHANNEL_IO>
	ether 0e:bc:32:8c:08:39
	media: autoselect
	status: inactive
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484
	options=400<CHANNEL_IO>
	ether 3e:47:26:cc:db:ba
	inet6 fe80::3c47:26ff:fecc:dbba%awdl0 prefixlen 64 scopeid 0x9
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
llw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether 3e:47:26:cc:db:ba
	inet6 fe80::3c47:26ff:fecc:dbba%llw0 prefixlen 64 scopeid 0xa
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
feth6702: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 2800
	ether 66:65:74:68:1a:2e
	peer: feth1702
	media: autoselect
	status: active
feth1702: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 5000 mtu 2800
	ether de:6c:d8:46:89:a2
	inet 172.22.22.2 netmask 0xffff0000 broadcast 172.22.255.255
	inet6 fe80::dc6c:d8ff:fe46:89a2%feth1702 prefixlen 64 scopeid 0xc
	inet6 fda0:9acf:233:27ef:de99:9383:ff75:8b6d prefixlen 88
	peer: feth6702
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
	inet6 fe80::1261:2fb:2ba2:d54f%utun0 prefixlen 64 scopeid 0xd
	nd6 options=201<PERFORMNUD,DAD>
utun1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
	inet6 fe80::6ff3:ef9:a481:9c4f%utun1 prefixlen 64 scopeid 0xe
	nd6 options=201<PERFORMNUD,DAD>
utun2: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1000
	inet6 fe80::ce81:b1c:bd2c:69e%utun2 prefixlen 64 scopeid 0xf
	nd6 options=201<PERFORMNUD,DAD>
utun3: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
	inet6 fe80::9383:904d:c951:598e%utun3 prefixlen 64 scopeid 0x10
	nd6 options=201<PERFORMNUD,DAD>
utun4: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
	inet6 fe80::3cd1:8cff:700d:52ef%utun4 prefixlen 64 scopeid 0x12
	nd6 options=201<PERFORMNUD,DAD>

On the RPi and macbook I also checked that nothing was holding onto port 5454, here is the result for the RPi:

❯ sudo lsof -i TCP -P              
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
cupsd      623 root    6u  IPv6  13676      0t0  TCP localhost:631 (LISTEN)
cupsd      623 root    7u  IPv4  13677      0t0  TCP localhost:631 (LISTEN)
vncserver  645 root   11u  IPv6  14636      0t0  TCP *:5900 (LISTEN)
vncserver  645 root   12u  IPv4  14637      0t0  TCP *:5900 (LISTEN)
vncserver  645 root   16u  IPv4  15003      0t0  TCP localhost:43434->localhost:39405 (ESTABLISHED)
vncserver  645 root   17u  IPv4  86119      0t0  TCP 192.168.1.44:5900->192.168.1.38:49564 (ESTABLISHED)
sshd       662 root    3u  IPv4  14515      0t0  TCP *:22 (LISTEN)
sshd       662 root    4u  IPv6  14517      0t0  TCP *:22 (LISTEN)
vncserver 1009   pi    8u  IPv4  15004      0t0  TCP localhost:39405->localhost:43434 (ESTABLISHED)
chromium- 1734   pi   31u  IPv4  20776      0t0  TCP 192.168.1.44:59132->stackoverflow.com:443 (ESTABLISHED)

@no-response no-response bot removed the MISSING : INFORMATION 🔍 Requested proper information/evidence about the Issue/PR in context. label Feb 19, 2022
@abhiTronix
Copy link
Owner

Add client.py on macOS set up to correct IP of RPi.
My RPi is assigned 192.168.1.44 and my macbook is 192.168.1.38

@iandol This pretty obvious that you're doing it wrong. It mentioned everywhere in NetGear docs(see any example) as well in example links I provided you for reference, that you need to "Replace the IP addresses in the code with Client's IP address, i.e. 192.168.1.38 in your case.". Kindly read docs properly before raising an issue here.

@abhiTronix abhiTronix added INVALID 🛑 This doesn't seem right or non-applicable or missing information QUESTION ❓ User asked about the working/usage of VidGear APIs. labels Feb 19, 2022
@iandol
Copy link
Contributor Author

iandol commented Feb 19, 2022

Yikes, you are completely correct of course. I'm very sorry. My brain made a strong assumption in a client + server system it was the server address that must be used...

As a slight emphasis for others who may make such an misguided assumption, perhaps the first comment on the example page could be slightly modified:

Note down the local IP-address of the client system; it is important to understand that the IP address of the client must be used on client and server. Replace this IP in the following code.

There were 3 problems I encountered with the client code. There is a missing import for Netgear, a wrong self, and apparently return cannot return any value inside an async:

Screenshot 2022-02-19 at 21 37 49

@abhiTronix
Copy link
Owner

abhiTronix commented Feb 20, 2022

@iandol I think all the instructions are already self-explanatory, no need to emphasis on (client) keyword in this particular example(except self typo, that you should address). However, You can surely make a new FAQ for NetGear https://abhitronix.github.io/vidgear/latest/help/netgear_faqs/ explaining the error and what one must do to avoid it. A PR would be great, but read the guidelines carefully: https://abhitronix.github.io/vidgear/latest/contribution/PR/

@abhiTronix abhiTronix added BUG 🐛 Vidgear api's error, flaw or fault DOCS 📜 Issue/PR is related to vidgear docs. WORK IN PROGRESS 🚧 currently been worked on. PR WELCOMED 📬 Related Pull Requests are welcomed for this issue! and removed INVALID 🛑 This doesn't seem right or non-applicable or missing information QUESTION ❓ User asked about the working/usage of VidGear APIs. WORK IN PROGRESS 🚧 currently been worked on. labels Feb 20, 2022
This was linked to pull requests Feb 23, 2022
@abhiTronix abhiTronix added SOLVED 🏁 This issue/PR is resolved now. Goal Achieved! and removed PR WELCOMED 📬 Related Pull Requests are welcomed for this issue! labels Feb 25, 2022
@abhiTronix abhiTronix added this to To do in VidGear v0.2.6 via automation Feb 25, 2022
@abhiTronix abhiTronix moved this from To do to Done in VidGear v0.2.6 Feb 25, 2022
@abhiTronix abhiTronix added this to the 0.2.6 milestone Feb 25, 2022
@abhiTronix abhiTronix linked a pull request Jul 5, 2022 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BUG 🐛 Vidgear api's error, flaw or fault DOCS 📜 Issue/PR is related to vidgear docs. SOLVED 🏁 This issue/PR is resolved now. Goal Achieved!
Projects
No open projects
2 participants