Why do I get the error "Timeout occurred while waiting for the String Terminator"?

24 Ansichten (letzte 30 Tage)
I am trying to create a TCP/IP client connection with a TCP/IP server using tcpclient() (formerly tcpip()). But I get the following error:
>> echotcpip("on",5000);
>> t = tcpclient("10.10.10.100",5000);
>> val = writeread(t,"ctrlcmd");
Error reading String.
Timeout occurred while waiting for the String Terminator.

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 27 Nov. 2020
What you see in the error message is the TCP/IP client saying that it expected a reply, but it did not receive a reply within the timeout period, or it did not receive the reply that it expected.
This can happen if the terminator is not configured correctly. In most cases, the TCP/IP server you are talking to will only recognize that it received a command if you end that command with terminator, such as "CR/LF".
To work around the issue, find out the correct terminator for your TCP/IP server, and specify it using the configureTerminator method:
>> t = tcpclient("10.10.10.100",5000)
>> configureTerminator(t,"CR/LF")
>> val = writeread(t,"ctrlcmd")
For the obsolete tcpip() command, the equivalent would be:
>> t = tcpip("10.10.10.100",5000)
>> t.Terminator = "CR/LF";
>> data = query(t,"ctrlcmd")

Weitere Antworten (0)

Produkte


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by