Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to perform subsequence connection after the first request #802

Open
pmth opened this issue Jul 8, 2024 · 0 comments
Open

Unable to perform subsequence connection after the first request #802

pmth opened this issue Jul 8, 2024 · 0 comments

Comments

@pmth
Copy link

pmth commented Jul 8, 2024

[x] I have read the Troubleshooting section of the ReadMe

What type of issues is this?

[ ] Request to support a new module

[ ] Bug or problem compiling the library
[x] Bug or issue with library functionality (ie, sending data over TCP/IP)
[x] Question or request for help

What are you working with?

Modem: SIMCOM 7080G (waveshare)
Main processor board: ESP32-S3
TinyGSM version: 0.12.0
Code:

bool testInternetConnection() {
  Serial.print("Connecting to ");
  Serial.print(server);
  Serial.print(":");
  Serial.println(port);

  if (!client.connected())
  {
    Serial.println("Client not connected, connecting ... ");
    if (!client.connect(server, port)) {
      Serial.println("Connection failed");
      return false;
    }
  }

  Serial.println("Connected!");

  // Make an HTTP GET request
  client.print(String("GET /get HTTP/1.1\r\n") +
               "Host: " + server + "\r\n" +
               "Connection: close\r\n\r\n");

  // Wait for response
  unsigned long timeout = millis();
  while (client.connected() && millis() - timeout < 10000) {
    while (client.available()) {
      char c = client.read();
      //Serial.print(c);
      timeout = millis(); // Reset timeout on activity
    }
  }

  //client.stop();
  //Serial.println();
  //Serial.println("Connection closed");

  return true;
}

Scenario, steps to reproduce

When system restarts, I am able to perform network requests. I tried both Http (Mqtt connection). However, the subsequence client.connect(server, port) calls are not successful.

modem.isNetworkConnected() and modem.isGprsConnected() are returning "true" and checking carrier, it showed that modem is connected to the network.

Expected result

I should be able to make connection to different servers or it should not be disconnected soon after successful request.

Actual result

The subsequence connection fails.

Debug and AT command log

Not sure how to do this, but I made change to the code so that it sends AT / response data to serial

Connecting to icanhazip.com:80
### AT:+CACLOSE= 0
DATA: 
### AT:+CACID= 0
DATA: OK
### AT:+CASSLCFG= 0 , SSL, 0
DATA: OK
### AT:+CAOPEN= 0 ,0,"TCP"," icanhazip.com ", 80
DATA: +CAOPEN:
DATA: OK
Connected!
### AT:+CASEND= 0 , 61
DATA: >
DATA: OK
### AT:+CARECV?
DATA: OK
### AT:+CASTATE?
DATA: +CASTATE:
DATA: OK
[28214] ### Got Data: 0
DATA:
### AT:+CARECV?
[28243] ### Closed:  0
DATA: +CARECV:
DATA: OK
### AT:+CASTATE?
DATA: +CASTATE:
DATA: OK
### AT:+CARECV= 0 , 63
DATA: +CARECV:
DATA: OK
### AT:+CARECV?
DATA: +CARECV:
DATA: OK

Subsequence:

Connecting to icanhazip.com:80
### AT:+CACLOSE= 0
DATA: OK
### AT:+CACID= 0
DATA: OK
### AT:+CASSLCFG= 0 , SSL, 0
DATA: OK
### AT:+CAOPEN= 0 ,0,"TCP"," icanhazip.com ", 80
DATA: 
Connection failed
### AT:+ CEREG ?
DATA: +CAOPEN: 0,23

OK

+CEREG:
DATA: OK
### AT:+CGATT?
DATA: +CGATT:
DATA: OK
### AT:+CNACT?
DATA: +CNACT:
DATA: +CNACT: 1,0,"0.0.0.0"
+CNACT: 2,0,"0.0.0.0"
+CNACT: 3,0,"0.0.0.0"

OK
Connecting to icanhazip.com:80
### AT:+CACLOSE= 0
DATA: OK
### AT:+CACID= 0
DATA: OK
### AT:+CASSLCFG= 0 , SSL, 0
DATA: OK
### AT:+CAOPEN= 0 ,0,"TCP"," icanhazip.com ", 80

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant