Feature Request: Please add an option to make ser2net fail if it detects 'Invalid port name/number' in a connection
Thank you for ser2net. It is an excellent and extremely useful program.
I have another instance of the Invalid port name/number: Invalid data to parameter on line ... problem.
This one seems to be caused by a serial adapter (StarTech ICUSB23216FD) that takes a while to come online properly, even after the device nodes have been created by the kernel.
This means that without some messing about to add delay before ser2net starts ser2net will start, but can't talk to any of the serial ports. Using a systemd path unit doesn't help in this specific case.
The simplest solution to this problem would be to have an option to make ser2net exit with an error code instead of just logging a message when it encounters this situation. That way the init system can be responsible for retrying the startup after the default delay time, and lots of the reported issues of this should disppear.
My preference would be for that to be the default behaviour. Using this on a serial console server I would far rather have an obviously failed process than a process that has started "successfully" but isn't actually doing the thing it needs to do.
Thank you.
So I'm assuming that you have a configuration that does a connect back, and when ser2net starts up it tries to open the serial port and fails. By default it does nothing, but you want ser2net to just fail. That actually might be a bit harder than one might think.
ser2net does not open the connector ports by default, it waits until it needs to. If the connector fails, it drops the incoming connection, and will try to open the connector again on a new incoming connection.
Have you tried the "connector-retry-time" option? That will cause ser2net to continually retry opening if the connector open fails. That would seem like the best way to solve this problem, assuming I am correct.
Any news on this?
Apologies, I have been away.
I have tried the connector-retry-time option, and it didn't help.
I see this in the systemd journal:
Feb 25 15:33:58 hostname systemd[1]: Started Serial port to network proxy.
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 53 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 61 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 69 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 77 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 85 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 93 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 101 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 109 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 117 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 125 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 133 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 141 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 149 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 157 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 165 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 173 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 181 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 189 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 197 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 205 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 213 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 221 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 229 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 237 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 245 column 0
Feb 25 15:33:58 hostname ser2net[898]: Invalid port name/number: Invalid data to parameter on line 253 column 0
I have port definitions in ser2net.yaml creating aliases to my serial devices:
# Port alias definitions. These use the serial number of the FTDI so are static.
define: &port00 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_ST211089-if00-port0
define: &port01 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_ST211090-if00-port0
define: &port02 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_ST211091-if00-port0
define: &port03 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_ST211092-if00-port0
define: &port04 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_ST211093-if00-port0
define: &port05 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_ST211094-if00-port0
define: &port06 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_ST211095-if00-port0
define: &port07 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_ST211096-if00-port0
define: &port08 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_ST211097-if00-port0
define: &port09 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_ST211098-if00-port0
define: &port10 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_ST211099-if00-port0
define: &port11 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_ST211100-if00-port0
define: &port12 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_ST211101-if00-port0
define: &port13 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_ST211102-if00-port0
define: &port14 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_ST211103-if00-port0
define: &port15 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_ST211104-if00-port0
and my connection definitions reference those, e.g:
# Connection definitions, defines the listen port (accepter) and the thing
# it connects to (connector).
connection: &v4con-serial-00
accepter: telnet,127.0.0.1,30000
enable: on
connector: serialdev,*(port00),local
options:
connector-retry-time: 10
accepter-retry-time: 10
connection: &v6con-serial-00
accepter: telnet,::1,30000
enable: on
connector: serialdev,*(port00),local
options:
connector-retry-time: 10
accepter-retry-time: 10
I can't connect to anything, even several minutes after the system has booted, unless I restart ser2net:
root@hostname:~# date; telnet localhost 30001
Tue 25 Feb 2025 15:43:53 NZDT
Trying ::1...
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
root@hostname:~# date; telnet localhost 30001
Tue 25 Feb 2025 15:44:58 NZDT
Trying ::1...
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
As soon as I restart ser2net it's fine. I assume this is because the USB serial adapter has come online enough that ser2net can find all its devices properly.
root@hostname:~# systemctl restart ser2net
root@hostname:~# systemctl status ser2net
● ser2net.service - Serial port to network proxy
Loaded: loaded (/lib/systemd/system/ser2net.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2025-02-25 15:45:32 NZDT; 5s ago
Docs: man:ser2net(8)
Main PID: 11826 (ser2net)
Tasks: 1 (limit: 19007)
Memory: 1.5M
CPU: 20ms
CGroup: /system.slice/ser2net.service
└─11826 /usr/sbin/ser2net -n -c /etc/ser2net.yaml -P /run/ser2net.pid
Feb 25 15:45:32 hostname systemd[1]: Starting Serial port to network proxy...
Feb 25 15:45:32 hostname systemd[1]: Started Serial port to network proxy.
root@hostname:~# telnet localhost 30001
Trying ::1...
Connected to localhost.
Escape character is '^]'.
2025-2-25T15:45:42 hostname
v6con-serial-01,115200N81,CLOCAL
Escape character is ^]
Press Enter to begin.
telnet> q
Connection closed.
The only workaround I've found to this is to create a timer that waits for 30 seconds and then starts ser2net:
[Install]
WantedBy=multi-user.target
[Timer]
OnActiveSec=30
AccuracySec=1
Unit=ser2net.service
This works, but means additional configuration on all the boxes I'm setting up and is a trap for new players. If ser2net failed on the invalid port reference systemd would just restart it automatically.
Thank you.
Ok, this is definitely something that needs to be fixed. connector-retry-time should do what you want, and it's obviously not, so I will fix that.
Well, I started looking in detail, and this has nothing to do with the connector part. It's the accepter part. I changed that message in November 2021 to read: Invalid accepter port name/number... because this confused me more than once. So that's a pretty old version of ser2net, and I know I have fixed bugs around this issue.
Is it possible to try the newest version of gensio and ser2net?
Thank you.
I will spin up a machine to try the newest version on. I'm restricted to whatever is in upstream repos on the current machine.
Well, I started looking in detail, and this has nothing to do with the connector part. It's the accepter part. I changed that message in November 2021 to read: Invalid accepter port name/number... because this confused me more than once.
Should the accepter-retry-time affect that?
Thanks.
On Tue, Feb 25, 2025 at 02:04:54PM -0800, Alasdair Muckart wrote:
amuckart left a comment (cminyard/ser2net#138)
Well, I started looking in detail, and this has nothing to do with the connector part. It's the accepter part. I changed that message in November 2021 to read: Invalid accepter port name/number... because this confused me more than once.
Should the
accepter-retry-timeaffect that?
Yes, but IIRC there were some issues around it.
Any news on this?
Closing on no info for a while. Please re-open if you have more info on this. Thanks.