mysgw: bind: Address already in use
-
Hi there!
Just started with my diy home automation project and as was following the https://www.mysensors.org/build/raspberry tutorial.
What I have done so far:
- Installed openhab2 on a rpi2
- followed all the steps of the guide
- wired the NRF24L01+ onto the rpi
Now, as my sensors haven't arrived yet, I would like to test if I can make the rpi and a adruino mini pro communicate via the radio.
The problem:
pi@raspberrypi:~ $ sudo /usr/local/bin/mysgw -d mysgw: Starting gateway... mysgw: Protocol version - 2.1.1 mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.1 mysgw: TSF:LRT:OK mysgw: TSM:INIT mysgw: TSF:WUR:MS=0 mysgw: TSM:INIT:TSP OK mysgw: TSM:INIT:GW MODE mysgw: TSM:READY:ID=0,PAR=0,DIS=0 mysgw: MCO:REG:NOT NEEDED mysgw: bind: Address already in use mysgw: Failed to bind! mysgw: MCO:BGN:STP mysgw: MCO:BGN:INIT OK,TSP=1 mysgw: accept: Bad file descriptor mysgw: accept: Bad file descriptor mysgw: accept: Bad file descriptor ... mysgw: accept: Bad file descriptor mysgw: TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0: mysgw: !TSF:MSG:LEN,0!=7 mysgw: accept: Bad file descriptor ...
I found what I think is a similar issue here: https://forum.mysensors.org/topic/1598/openhab-2-0-binding/303
But the process was overwhelming for a a beginner at my level.
There probably is a step I am missing, but couldn't locate it.
The problem with all these tutorials is that they tell what to do but don't explain what you are doing and why. If anyone knows any good basic principle "text books" on the subject, please add a link or something.
Regards,
Fipster
-
Looks like another service is already blocking the port for the gateway. My guess: there already is a instance of the gateway running. Check with: "ps -ax" command. You should see all running process.
-
Thank you for quick response!
There are the running processes:
PID TTY STAT TIME COMMAND 1 ? Ss 0:03 /sbin/init splash 2 ? S 0:00 [kthreadd] 3 ? S 0:01 [ksoftirqd/0] 5 ? S< 0:00 [kworker/0:0H] 7 ? S 0:15 [rcu_sched] 8 ? S 0:00 [rcu_bh] 9 ? S 0:00 [migration/0] 10 ? S 0:00 [migration/1] 11 ? S 0:01 [ksoftirqd/1] 13 ? S< 0:00 [kworker/1:0H] 14 ? S 0:00 [migration/2] 15 ? S 0:01 [ksoftirqd/2] 17 ? S< 0:00 [kworker/2:0H] 18 ? S 0:00 [migration/3] 19 ? S 0:02 [ksoftirqd/3] 21 ? S< 0:00 [kworker/3:0H] 22 ? S 0:00 [kdevtmpfs] 23 ? S< 0:00 [netns] 24 ? S< 0:00 [perf] 25 ? S 0:00 [khungtaskd] 26 ? S< 0:00 [writeback] 27 ? S< 0:00 [crypto] 28 ? S< 0:00 [bioset] 29 ? S< 0:00 [kblockd] 30 ? S 0:00 [kworker/0:1] 31 ? S< 0:00 [rpciod] 32 ? S 0:00 [kswapd0] 33 ? S< 0:00 [vmstat] 34 ? S 0:00 [fsnotify_mark] 35 ? S< 0:00 [nfsiod] 44 ? S< 0:00 [kthrotld] 45 ? S< 0:00 [bioset] 46 ? S< 0:00 [bioset] 47 ? S< 0:00 [bioset] 48 ? S< 0:00 [bioset] 49 ? S< 0:00 [bioset] 50 ? S< 0:00 [bioset] 51 ? S< 0:00 [bioset] 52 ? S< 0:00 [bioset] 53 ? S< 0:00 [bioset] 54 ? S< 0:00 [bioset] 55 ? S< 0:00 [bioset] 56 ? S< 0:00 [bioset] 57 ? S< 0:00 [bioset] 58 ? S< 0:00 [bioset] 59 ? S< 0:00 [bioset] 60 ? S< 0:00 [bioset] 61 ? S< 0:00 [bioset] 62 ? S< 0:00 [bioset] 63 ? S< 0:00 [bioset] 64 ? S< 0:00 [bioset] 65 ? S< 0:00 [bioset] 66 ? S< 0:00 [bioset] 67 ? S< 0:00 [bioset] 68 ? S< 0:00 [bioset] 69 ? S< 0:00 [VCHIQ-0] 70 ? S< 0:00 [VCHIQr-0] 71 ? S< 0:00 [VCHIQs-0] 72 ? S< 0:00 [iscsi_eh] 73 ? S< 0:00 [dwc_otg] 75 ? S< 0:00 [DWC Notificatio] 77 ? S 0:00 [VCHIQka-0] 78 ? S< 0:00 [deferwq] 80 ? S< 0:00 [bioset] 81 ? S 0:01 [mmcqd/0] 82 ? S 0:00 [jbd2/mmcblk0p2-] 83 ? S< 0:00 [ext4-rsv-conver] 87 ? S< 0:00 [ipv6_addrconf] 104 ? S< 0:00 [kworker/0:1H] 131 ? Ss 0:06 /lib/systemd/systemd-journald 135 ? Ss 0:00 /lib/systemd/systemd-udevd 283 ? S 0:00 [kworker/2:2] 367 ? Ssl 0:01 /usr/sbin/rsyslogd -n 368 ? Ss 0:00 /usr/sbin/cron -f 370 ? Ss 0:00 avahi-daemon: running [raspberrypi.local] 371 ? Ss 1:51 /usr/local/bin/mysgw 372 ? Ss 0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfil 375 ? S 0:00 avahi-daemon: chroot helper 379 ? S< 0:00 [cfg80211] 380 ? Ss 0:00 /sbin/dhcpcd -q -b 405 ? Ss 0:00 /lib/systemd/systemd-logind 414 ? S< 0:00 [kworker/3:1H] 430 ? Ss 0:00 /usr/sbin/sshd -D 437 ? Ss 0:00 /bin/bash /usr/share/openhab2/runtime/bin/karaf server 454 ? Ssl 0:00 /usr/sbin/lightdm 596 ? Ss 0:00 /usr/sbin/thd --daemon --triggers /etc/triggerhappy/triggers.d/ --so 619 tty7 Ssl+ 0:03 /usr/lib/xorg/Xorg :0 -seat seat0 -auth /var/run/lightdm/root/:0 -no 620 tty1 Ss 0:00 /bin/login -f 621 ? Ss 0:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 106:111 622 ? Ss+ 0:00 /sbin/agetty --keep-baud 115200 38400 9600 ttyAMA0 vt102 629 ? S< 0:00 [kworker/2:1H] 633 ? Ss 0:00 /lib/systemd/systemd --user 638 ? S 0:00 (sd-pam) 646 tty1 S+ 0:00 -bash 703 ? Sl 0:00 lightdm --session-child 13 16 723 ? Ssl 0:00 /usr/bin/lxsession -s LXDE-pi -e LXDE 782 ? Sl 1:53 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc 804 ? Ss 0:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session x-sessio 807 ? S 0:00 /usr/bin/dbus-launch --exit-with-session x-session-manager 808 ? Ss 0:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --sessio 818 ? Sl 0:00 /usr/lib/gvfs/gvfsd 822 ? Sl 0:00 /usr/lib/gvfs/gvfsd-fuse /run/user/1000/gvfs -f -o big_writes 823 ? S< 0:00 [kworker/1:1H] 997 ? S 0:01 openbox --config-file /home/pi/.config/openbox/lxde-pi-rc.xml 999 ? Sl 0:00 lxpolkit 1003 ? Sl 0:01 pcmanfm --desktop --profile LXDE-pi 1009 ? Ss 0:00 /usr/bin/ssh-agent -s 1018 ? Ssl 0:00 /usr/lib/policykit-1/polkitd --no-debug 1023 ? S 0:00 sh -c zenity --info --text="Your Raspbian system has been upgraded t 1025 ? Sl 0:01 zenity --info --text=Your Raspbian system has been upgraded to the l 1049 ? Sl 0:00 /usr/lib/gvfs/gvfs-udisks2-volume-monitor 1051 ? Ssl 0:00 /usr/lib/udisks2/udisksd --no-debug 1063 ? SNsl 0:00 /usr/lib/rtkit/rtkit-daemon 1073 ? Sl 0:00 /usr/lib/gvfs/gvfs-goa-volume-monitor 1077 ? Sl 0:00 /usr/lib/gvfs/gvfs-mtp-volume-monitor 1083 ? Sl 0:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor 1089 ? Sl 0:00 /usr/lib/gvfs/gvfs-afc-volume-monitor 1091 ? Ss 0:00 /usr/lib/bluetooth/bluetoothd 1104 ? S 0:00 /bin/sh /usr/bin/start-pulseaudio-x11 1105 ? S 0:00 /usr/bin/xprop -root -spy 1121 ? Ssl 0:00 /usr/lib/menu-cache/menu-cached /tmp/.menu-cached-:0-pi 1138 ? Sl 0:00 /usr/lib/gvfs/gvfsd-trash --spawner :1.1 /org/gtk/gvfs/exec_spaw/0 1508 ? S 0:00 [kworker/u8:0] 1523 ? S 0:00 [kworker/1:2] 1556 ? S 0:00 [kworker/3:2] 1641 ? Sl 0:08 lxpanel --profile LXDE-pi 1661 ? S 0:00 [spi0] 1747 ? S 0:00 [kworker/2:0] 1762 ? Ss 0:00 sshd: pi [priv] 1769 ? R 0:00 sshd: pi@pts/0 1771 pts/0 Ss 0:00 -bash 1874 ? Ssl 0:00 /usr/lib/packagekit/packagekitd 1883 ? S 0:00 [kworker/3:1] 2153 ? S 0:00 [kworker/1:0] 2212 ? S 0:00 [kworker/0:0] 2241 ? S 0:00 [kworker/u8:2] 2286 pts/0 R+ 0:00 ps -ax
-
@fipster you already have one mysgw running
371 ? Ss 1:51 /usr/local/bin/mysgw
-
Hello,
I asking for help with same question. How I see there is no solution, so I try to explain step by step what I did and whats the problem I have.-
I install Domoticz on fresh Raspberry Pi Raspbian image
-
Build a Raspberry Pi Ethernet Gateway by instructions (https://www.mysensors.org/build/raspberry)
- git clone https://github.com/mysensors/MySensors.git --branch master
- cd MySensors
- sudo ./configure --my-transport=nrf24 --my-gateway=ethernet --my-port=5003
-
After that comand I have answer, that my SoC and Type of machine unknown (I using RPi 2):
[SECTION] Detecting target machine. [OK] machine detected: SoC=unknown, Type=unknown, CPU=armv7l.
But I found the solution about that in forum, where I change two lines of the configure file to "BCM2835":
function detect_machine { ... case $hardware in ... BCM2835) soc="BCM2835" if [[ $machine == "Raspberry"* ]]; then local rev=($(detect_rpi_revision)) if [[ $rev == "a02082" || $rev == "a22082" ]]; then tp="RPi3" else tp="Rpi2" fi fi ;; ...
After changing it , all looks fine.
- I repeat
- sudo ./configure --my-transport=nrf24 --my-gateway=ethernet --my-port=5003
My board is recognized so I continue with gateway building instructions...
- sudo make
- sudo ./bin/mysgw -h
- sudo ./bin/mysgw -d
And I got results with no errors, gateway is running. Continue with comands
- sudo make install
- sudo systemctl enable mysgw.service
- sudo systemctl start mysgw.service
No errors. I connect one LED strip node to Domoticz and its working perfectly.
But after ~10 minutes trying to on/off LED strip it doesn't work anymore. Nothing was changed. Checking the gateway with command:- sudo ./bin/mysgw -d
And getting:
Sep 24 21:37:15 raspberrypi mysgw: accept: Bad file descriptor Sep 24 21:37:15 raspberrypi mysgw: accept: Bad file descriptor Sep 24 21:37:15 raspberrypi mysgw: accept: Bad file descriptor Sep 24 21:37:15 raspberrypi mysgw: accept: Bad file descriptor Sep 24 21:37:15 raspberrypi mysgw: accept: Bad file descriptor Sep 24 21:37:15 raspberrypi mysgw: accept: Bad file descriptor
Output of "ps -ax" command:
PID TTY STAT TIME COMMAND 1 ? Ss 0:02 /sbin/init splash 2 ? S 0:00 [kthreadd] 3 ? S 0:00 [ksoftirqd/0] 5 ? S< 0:00 [kworker/0:0H] 6 ? S 0:00 [kworker/u8:0] 7 ? S 0:01 [rcu_sched] 8 ? S 0:00 [rcu_bh] 9 ? S 0:00 [migration/0] 10 ? S< 0:00 [lru-add-drain] 11 ? S 0:00 [cpuhp/0] 12 ? S 0:00 [cpuhp/1] 13 ? S 0:00 [migration/1] 14 ? S 0:00 [ksoftirqd/1] 16 ? S< 0:00 [kworker/1:0H] 17 ? S 0:00 [cpuhp/2] 18 ? S 0:00 [migration/2] 19 ? S 0:00 [ksoftirqd/2] 21 ? S< 0:00 [kworker/2:0H] 22 ? S 0:00 [cpuhp/3] 23 ? S 0:00 [migration/3] 24 ? S 0:00 [ksoftirqd/3] 26 ? S< 0:00 [kworker/3:0H] 27 ? S 0:00 [kdevtmpfs] 28 ? S< 0:00 [netns] 29 ? S 0:00 [khungtaskd] 30 ? S 0:00 [oom_reaper] 31 ? S< 0:00 [writeback] 32 ? S 0:00 [kcompactd0] 33 ? S< 0:00 [crypto] 34 ? S< 0:00 [bioset] 35 ? S< 0:00 [kblockd] 36 ? S< 0:00 [watchdogd] 37 ? S 0:00 [kworker/0:1] 38 ? S< 0:00 [rpciod] 39 ? S< 0:00 [xprtiod] 40 ? S 0:00 [kswapd0] 41 ? S< 0:00 [vmstat] 42 ? S< 0:00 [nfsiod] 52 ? S< 0:00 [kthrotld] 53 ? S< 0:00 [bioset] 54 ? S< 0:00 [bioset] 55 ? S< 0:00 [bioset] 56 ? S< 0:00 [bioset] 57 ? S< 0:00 [bioset] 58 ? S< 0:00 [bioset] 59 ? S< 0:00 [bioset] 60 ? S< 0:00 [bioset] 61 ? S< 0:00 [bioset] 62 ? S< 0:00 [bioset] 63 ? S< 0:00 [bioset] 64 ? S< 0:00 [bioset] 65 ? S< 0:00 [bioset] 66 ? S< 0:00 [bioset] 67 ? S< 0:00 [bioset] 68 ? S< 0:00 [bioset] 69 ? S< 0:00 [bioset] 70 ? S< 0:00 [bioset] 71 ? S< 0:00 [bioset] 72 ? S< 0:00 [bioset] 73 ? S< 0:00 [bioset] 74 ? S< 0:00 [bioset] 75 ? S< 0:00 [bioset] 76 ? S< 0:00 [bioset] 77 ? S< 0:00 [iscsi_eh] 78 ? S< 0:00 [dwc_otg] 80 ? S< 0:00 [DWC Notificatio] 81 ? S< 0:00 [VCHIQ-0] 82 ? S< 0:00 [VCHIQr-0] 83 ? S< 0:00 [VCHIQs-0] 84 ? S 0:00 [VCHIQka-0] 85 ? S< 0:00 [SMIO] 88 ? S< 0:00 [bioset] 89 ? S 0:00 [mmcqd/0] 90 ? S 0:00 [jbd2/mmcblk0p2-] 91 ? S< 0:00 [ext4-rsv-conver] 93 ? S 0:00 [kworker/3:1] 94 ? S< 0:00 [ipv6_addrconf] 109 ? S< 0:00 [kworker/1:1H] 110 ? S 0:00 [kworker/u8:1] 115 ? Ss 0:11 /lib/systemd/systemd-journald 144 ? S 0:00 [kworker/1:3] 150 ? Ss 0:00 /lib/systemd/systemd-udevd 200 ? S 0:00 [spi0] 238 ? S 0:00 [kworker/3:2] 266 ? Ssl 0:00 /lib/systemd/systemd-timesyncd 288 ? Ss 0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation 291 ? Ss 0:00 /usr/sbin/cron -f 292 ? Ssl 0:04 /usr/sbin/rsyslogd -n 293 ? Ss 0:00 avahi-daemon: running [raspberrypi.local] 295 ? Rs 80:53 /usr/local/bin/mysgw 297 ? Ss 0:00 /lib/systemd/systemd-logind 299 ? Ss 0:00 /usr/sbin/thd --triggers /etc/triggerhappy/triggers.d/ --socket /run/thd.socket --user nobody --deviceglob /dev/input/event* 309 ? S 0:00 avahi-daemon: chroot helper 320 ? S< 0:00 [cfg80211] 324 ? Ss 0:00 /sbin/dhcpcd -q -b 359 ? Ss 0:00 /usr/sbin/sshd -D 378 ? Ssl 0:00 /usr/sbin/lightdm 381 ? S< 0:00 [kworker/2:1H] 390 tty1 Ss 0:00 /bin/login -f 393 ? Ss+ 0:00 /sbin/agetty --keep-baud 115200,38400,9600 ttyAMA0 vt220 400 tty7 Ssl+ 0:03 /usr/lib/xorg/Xorg :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch 402 ? Ssl 0:16 /home/pi/domoticz/domoticz -daemon -www 8080 -sslwww 443 403 ? S< 0:00 [kworker/3:1H] 431 ? Sl 0:00 lightdm --session-child 14 17 439 ? Ss 0:00 /lib/systemd/systemd --user 442 ? S 0:00 (sd-pam) 447 ? Ssl 0:00 /usr/bin/lxsession -s LXDE-pi -e LXDE 456 ? Ss 0:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation 501 tty1 S+ 0:00 -bash 520 ? Ss 0:00 /usr/bin/ssh-agent x-session-manager 526 ? Ssl 0:00 /usr/lib/gvfs/gvfsd 531 ? Sl 0:00 /usr/lib/gvfs/gvfsd-fuse /run/user/1000/gvfs -f -o big_writes 547 ? S 0:01 openbox --config-file /home/pi/.config/openbox/lxde-pi-rc.xml 549 ? Sl 0:00 lxpolkit 551 ? Sl 0:12 lxpanel --profile LXDE-pi 553 ? Sl 0:01 pcmanfm --desktop --profile LXDE-pi 561 ? Ss 0:00 /usr/bin/ssh-agent -s 570 ? Ssl 0:00 /usr/lib/policykit-1/polkitd --no-debug 585 ? Ssl 0:00 /usr/lib/menu-cache/menu-cached /run/user/1000/menu-cached-:0 589 ? Ssl 0:00 /usr/lib/gvfs/gvfs-udisks2-volume-monitor 592 ? Ssl 0:00 /usr/lib/udisks2/udisksd --no-debug 603 ? Ssl 0:00 /usr/lib/gvfs/gvfs-goa-volume-monitor 607 ? Ssl 0:00 /usr/lib/gvfs/gvfs-mtp-volume-monitor 611 ? Ssl 0:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor 620 ? Ssl 0:00 /usr/lib/gvfs/gvfs-afc-volume-monitor 633 ? Sl 0:00 /usr/lib/gvfs/gvfsd-trash --spawner :1.4 /org/gtk/gvfs/exec_spaw/0 733 ? S 0:00 sudo ./bin/mysgw -d 737 ? R 80:45 ./bin/mysgw -d 751 ? S< 0:00 [kworker/0:1H] 760 ? S 0:00 [kworker/0:0] 761 ? S 0:00 [kworker/1:1] 766 ? Ss 0:00 sshd: pi [priv] 776 ? R 0:01 sshd: pi@pts/1 779 pts/1 Ss 0:00 -bash 805 pts/1 T 0:00 sudo ./bin/mysgw -d 809 pts/1 T 0:25 ./bin/mysgw -d 850 ? S 0:00 [kworker/2:1] 857 ? S 0:00 [kworker/2:0] 862 pts/1 R+ 0:00 ps -ax
cat /sys/firmware/devicetree/base/model
Raspberry Pi 2 Model B Rev 1.1
Don't know how to fix that
Sep 24 21:37:15 raspberrypi mysgw: accept: Bad file descriptorLooks like I using gateway building instructions step by step, but something is missing... Thanks.
-
-
@jacikaas as can be seen from the ps output, mysgw is already running:
295 ? Rs 80:53 /usr/local/bin/mysgw
It is running because you started it with
sudo systemctl start mysgw.service
So when you try to start another instance of mysgw by running
sudo ./bin/mysgw -d
the new instance tries to start listening on the same port, which it can't because it is already in use.
As mentioned in the troubleshooting section, look in /var/log/syslog to see the gateway output of the existing instance. Don't start a new one.
Also, it seems your sudo key has gotten stuck If you missed that not every command is preceeded by sudo in the build instructions, maybe it is worth considering that you missed something else?
-
Thank You for the answer.
@mfalkvidd said in mysgw: bind: Address already in use:
As mentioned in the troubleshooting section, look in /var/log/syslog to see the gateway output of the existing instance. Don't start a new one.
Ohh... Thats a lot more clear now... I thought command "sudo ./bin/mysgw -d" is not a service start, but just something like output mirror. Like "tail". Could I somehow use tail for watching real time output on ./bin/mysgw -d ?
Also, it seems your sudo key has gotten stuck If you missed that not every command is preceeded by sudo in the build instructions, maybe it is worth considering that you missed something else?
Sorry for dumb questions, but how I make that sudo key stuck? It's becose of that I start a few mysgw services?
Another silly question, becose I'm very "advanced user" in UNIX, my best friend is called desktop there, and I know basically just install, nano, cp, rm commands, I need to ask Is there should be difference if I will use "make" instead of "sudo make". Sudo means that I run this command by root user, but does it make difference between "make" or "sudo make"? And if I remember clearly if I run only "make" - raspberry pi starts to swearing, but with sudo, it's ok.
When I install the gateway by command "sudo make install" I can see that installing was successful, there is info that if I want to run this on boot I need to run two lines:
- sudo systemctl enable mysgw.service
- sudo systemctl start mysgw.service
But now, I guess, I do not need them both, because start on boot is described in "sudo make install"?