sendTCPClient regularly errors

Everything about programming the platform and using the Waspmote API
Post Reply
diunu
Posts: 6
Joined: Fri Nov 08, 2019 2:53 am
Company: iUNU, Inc.

sendTCPClient regularly errors

Post by diunu » Fri Nov 08, 2019 6:07 pm

Hoping to get some help with having the sendTCPClient to work reliably on some new waspmotes we've received. We already have dozens working, so I'm uncertain if the problem is related to any API updates with the latest version of the software. We're attempting to regularly capture and send data on a schedule, but most of the time calls to sendTCPClient just results in an error from the WaspMote device.

The relevant code is called after WiFi is up and configured with an IP, and utilizes a static IP for HOST, a port open and listening on REMOTE_PORT.

Code: Select all

//set the tcp
    error = WIFI_PRO.setTCPclient( HOST, REMOTE_PORT, LOCAL_PORT);

    // check response
    if (error == 0)
    {
      // get socket handle (from 0 to 9)
      socket_handle = WIFI_PRO._socket_handle;
      USB.print("opened socket");
    }
    else
    {
      USB.println(F("3.1. Error calling 'setTCPclient' function"));
      WIFI_PRO.printErrorCode();
      status = false;   
    }
Would love to understand if this indicates some hardware problem, or the best way to debug why the WaspMote is failing setting up a socket appropriately.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: sendTCPClient regularly errors

Post by libelium-dev » Mon Nov 11, 2019 9:06 am

Hi,

What error code does return the WiFi module? What API version did you use to upload the code?

Could you please check the firmware version of both modules using the following code?

Code: Select all

#include <WaspWIFI_PRO.h>

// choose socket (SELECT USER'S SOCKET)
///////////////////////////////////////
uint8_t socket = SOCKET0;
///////////////////////////////////////

uint8_t error;

void setup()
{
  USB.println(F("Start program"));
  //////////////////////////////////////////////////
  // 1. Switch ON
  //////////////////////////////////////////////////
  error = WIFI_PRO.ON(socket);

  if ( error == 0 )
  {
    USB.println(F("WiFi switched ON"));
  }
  else
  {
    USB.println(F("WiFi did not initialize correctly"));
  }

  ////////////////////////////////////////////////
  // 2. firmware version
  ////////////////////////////////////////////////
  error = WIFI_PRO.getFirmwareVersion();

  if (error == 0)
  {
    USB.print(F("Firmaware version: "));
    USB.println(WIFI_PRO._firmwareVersion);
  }
  else
  {
    USB.println(F("getIP error"));
  }

  //////////////////////////////////////////////////
  // 3. Switch OFF
  //////////////////////////////////////////////////
  WIFI_PRO.OFF(socket);
  USB.println(F("WiFi switched OFF\n\n"));
}

void loop()
{
}
Could you please share the full code with us? So we will debug the issue more in deep.

Regards

diunu
Posts: 6
Joined: Fri Nov 08, 2019 2:53 am
Company: iUNU, Inc.

Re: sendTCPClient regularly errors

Post by diunu » Mon Nov 11, 2019 5:59 pm

Using latest API 043 and currently downloaded SDK/IDE on linux. What is the best way to securely send our code to you?

diunu
Posts: 6
Joined: Fri Nov 08, 2019 2:53 am
Company: iUNU, Inc.

Re: sendTCPClient regularly errors

Post by diunu » Mon Nov 11, 2019 7:17 pm

Firmaware version: ID811d26 11.8.2017 (BCOM)

Here is the output when trying to setup the socket. Previously we had it use a local port, which just returns an error ), when I remove the localport option, I at least get the more verbose timeout error:

Code: Select all

1. WiFi switched ON
2. WiFi is connected OK Time(ms):5596
IP address: 172.29.0.43
3.1. Error calling 'setTCPclient' function
[WIFI] ==> ERROR CODE: Timeout
WiFi switched OFF
I can confirm with TCP dump that we do not see any packets coming from the waspmote to the tcp server when the request to setTCPclient produces its timeout so it is a purely client and waspmote hardware problem. How and where do I try other firmware revisions? I can't seem to find this information within the technical guide, or other online documentation.

diunu
Posts: 6
Joined: Fri Nov 08, 2019 2:53 am
Company: iUNU, Inc.

Re: sendTCPClient regularly errors

Post by diunu » Mon Nov 11, 2019 7:26 pm

Unfortunately the maximum character size allowed by your forums is exceeded when trying to share the code with you. Please provide an alternate contact method to share this code with you.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: sendTCPClient regularly errors

Post by libelium-dev » Tue Nov 12, 2019 8:41 am

Hi,

You can use a link to google drive, dropbox, etct to share the code.

Could you please try to perform a ping to your server? Does it work?
http://www.libelium.com/development/was ... o-05-ping/

Regards

diunu
Posts: 6
Joined: Fri Nov 08, 2019 2:53 am
Company: iUNU, Inc.

Re: sendTCPClient regularly errors

Post by diunu » Sat Dec 14, 2019 12:13 am

Just FYI Ping didn't work in this case. Turns out this was traced to a low level bug in the networking stack based upon systemd on the the destination for publishing. The bug was specific to dual homed interfaces (Wifi and ethernet), in where the actual route metrics weren't passed to the kernel for local connections, so traffic would come in on one interface and a response would be sent on another. Fun!

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: sendTCPClient regularly errors

Post by libelium-dev » Mon Dec 16, 2019 11:47 am

Glad to hear that you found the root cause of the problem!
Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest