TCP connect failed

We are trying to add the ability to establish a TCP connection from the development board to a remote TCP server via OTBR to Nordic's matter routine and 52840 development board.

Refer to github.com/.../README_TCP.md, we have set up the network environment, and mentioned in the document, using the shell command on the terminal of success, And we set up a tcp connection with our own tcp server, the effect is similar:

> tcp connect 172.17.0.1 1234
Connecting to synthesized IPv6 address: fdde:ad00:beef:2:0:0:ac11:1
Done

Next, we created our own thread, and called the API provided by OpenThread for network programming instead of shell in the thread, trying to establish a tcp connection, but encountered the connect API returned -1, and there was no more information error.

We captured the connection message passed by the Raspberry PI, and successfully established a TCP connection under shell conditions.

What we now want to know is: on a Matter over Thread device, if you want to write some code to establish a connection with the tcp server and send and receive some tcp content, as the shell command does, whether there is a more direct reference document or code than analyzing the shell source code.

Or: Do you have suggestions on what to check when a connection is Reset by a client (the terminal itself) to abandon the connection? Neither Zephyr nor OpenThread's existing error messages can help us understand why the connection is being abandoned by the terminal?

Look forward to your comments, thank you!

Parents
  • Hi,

    I have started looking into this and will come back tomorrow.

    In the meantime, can you share the code you used for trying to establish a TCP connection?

    but encountered the connect API returned -1, and there was no more information error.

    Did you check the errno error code? If you are not familiar with this, here is an example of how to use errno:

    int err
    
    err = connect(sock, (struct sockaddr *)&server, sizeof(struct sockaddr_in));
    if (err < 0) {
    	LOG_INF("Connecting to server failed, error: %d, %s", errno, strerror(errno));
    	return -errno;
    }

    Best regards,
    Marte

  • We captured the connection message passed by the Raspberry PI, and successfully established a TCP connection under shell conditions:

    Create thread, call connect interface failed to establish TCP connection corresponding to:



    It seems that in the event of an exception, after the second handshake, the client sends the RST flag to reset the connection, so I wonder why the RST flag was sent during this connection.
Reply
  • We captured the connection message passed by the Raspberry PI, and successfully established a TCP connection under shell conditions:

    Create thread, call connect interface failed to establish TCP connection corresponding to:



    It seems that in the event of an exception, after the second handshake, the client sends the RST flag to reset the connection, so I wonder why the RST flag was sent during this connection.
Children
Related