ravelox / pimidi

Raspberry Pi RTP MIDI
164 stars 38 forks source link

net_socket_init: Cannot create socket: Cannot assign requested address #71

Closed alpho-gav closed 4 years ago

alpho-gav commented 4 years ago

Following up on Issue #65

It seems like I'm having the same problem again. This problem happens when I set a static IP in /etc/dhcpcd.conf

When I don't have a static IP, it works fine.

alpho-gav commented 4 years ago

You know, it might have to do with my code I'm using the share wlan to eth0 as well?

ip_address="10.0.0.1" netmask="255.255.255.0" dhcp_range_start="10.0.0.2" dhcp_range_end="10.0.0.100" dhcp_time="12h" eth="eth0" wlan="wlan0"

sudo systemctl start network-online.target &> /dev/null

sudo iptables -F sudo iptables -t nat -F sudo iptables -t nat -A POSTROUTING -o $wlan -j MASQUERADE sudo iptables -A FORWARD -i $wlan -o $eth -m state --state RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i $eth -o $wlan -j ACCEPT

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

sudo ifconfig $eth $ip_address netmask $netmask

sudo ip route del 0/0 dev $eth &> /dev/null

sudo systemctl stop dnsmasq

sudo rm -rf /etc/dnsmasq.d/* &> /dev/null

echo "interface=$eth\n\ bind-interfaces\n\ server=8.8.8.8\n\ domain-needed\n\ bogus-priv\n\ dhcp-range=$dhcp_range_start,$dhcp_range_end,$dhcp_time" > /tmp/custom-dnsmasq.conf

sudo cp /tmp/custom-dnsmasq.conf /etc/dnsmasq.d/custom-dnsmasq.conf sudo systemctl start dnsmasq

sudo ifconfig eth0 down sleep 1 sudo ifconfig eth0 up sleep 1

ravelox commented 4 years ago

so I have this right, you have the Pi connected to the Windows machine via eth0 through a switch/hub and packets are forwarded from eth0 to wlan0?

ravelox commented 4 years ago

This might be a timing issue. I can see that when I run those commands, the interface doesn't get the ip address immediately after the ifconfig eth0 up. There is a delay of a few seconds.

For the final sleep, can you try with ( say ) 20 seconds?

ravelox commented 4 years ago

`pi@cheapnas:~ $ ./issue71.sh && raveloxmidi -c raveloxmidi.conf

alpho-gav commented 4 years ago

I'll give it a shot, thank you.

alpho-gav commented 4 years ago

I put the Internet Sharing code as a crontab process. The Pimidi code now runs when the "Pi User" logs in. I have no issues. Must have been a timing problem.

Thank you