CC3000 Failed Connections
Moderators: adafruit_support_bill, adafruit

CC3000 Failed Connections

by tinkeringtech on Fri Oct 25, 2013 9:10 pm

I modified the CC3000 webclient code to periodically poll a webpage that loads some sensory data to a MYSQL db. I'm using a get request that sends a string to a .php page.

The CC3000 is able to authenticate and get a good wifi connection and it starts transmitting the GET requests. The issue is that after 3-4 successful data dispatches, the connection fails. I can't quite figure out why. I see that the adafruit default code has a cc3000.disconnect() since there is a chance the module could freak out.

Is this one of those module freak-out scenarios I'm dealing with? I did not want to do a disconnect since I would have to deal with a reconnection; I will be transmitting the data every 2 seconds or so. I also tried a www.close(), but this did not help. Thanks for any assistance you can provide in solving this issue.

Connect to x.x.x.x:80
Inserted data

Connect to x.x.x.x:80
Inserted data

Connect to x.x.x.x:80
Connection failed


Connect to x.x.x.x:80
Inserted data

Code: Select all | TOGGLE FULL SIZE
#define WEBSITE      "www.somewebsite.com"
#define WEBPAGE      "/updatedata.php?data1=1234567&data2=8901234"
void loop(void)
{
 
    /* Try connecting to the website */
  Adafruit_CC3000_Client www = cc3000.connectTCP(ip, 80);
  if (www.connected()) {
   
    www.fastrprint(F("GET "));
    www.fastrprint(WEBPAGE);
    www.fastrprint(F(" HTTP/1.0\r\n"));
    www.fastrprint(F("Host: "));
    www.fastrprint(WEBSITE);
    www.fastrprint(F("\n"));
    www.fastrprint(F("Connection: close\n"));
    www.fastrprint(F("\n"));
    www.println();

    Serial.println(F("Inserted data\n"));
 
  } else {
    Serial.println(F("Connection failed"));   
    return;
  }

  /* You need to make sure to clean up after yourself or the CC3000 can freak out */
  /* the next time your try to connect ... */
 // Serial.println(F("\n\nDisconnecting"));
 // cc3000.disconnect();
 delay(2000);
}
Its not about brilliance, its all about persistence
www.tinkeringtech.com
tinkeringtech
 
Posts: 52
Joined: Wed Nov 23, 2011 9:08 pm

Re: CC3000 Failed Connections

by adafruit_support_rick on Sat Oct 26, 2013 3:55 am

You don't want to do the cc3000.disconnect, as this will disconnect you from the access point.
The www.close should close the connection properly, allowing you to reconnect two seconds later.
I don't see where you put the www.close call in your code?

Do you actually need to close the connection? Why not just connect once and leave it open?
User avatar
adafruit_support_rick
 
Posts: 12102
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: CC3000 Failed Connections

by tinkeringtech on Sat Oct 26, 2013 9:20 am

Rick,
I did include the close() in a previous test; just left it out for the code I posted.
I actually don't need to close() the connection, and would rather just keep the connection open. Any thoughts on why I'm seeing the connection failures?

Thanks.
Its not about brilliance, its all about persistence
www.tinkeringtech.com
tinkeringtech
 
Posts: 52
Joined: Wed Nov 23, 2011 9:08 pm

Re: CC3000 Failed Connections

by adafruit_support_rick on Sat Oct 26, 2013 11:04 am

Where did you have the close? Before or after the delay(2000)?
User avatar
adafruit_support_rick
 
Posts: 12102
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: CC3000 Failed Connections

by tinkeringtech on Sat Oct 26, 2013 11:20 am

Before the delay.
Its not about brilliance, its all about persistence
www.tinkeringtech.com
tinkeringtech
 
Posts: 52
Joined: Wed Nov 23, 2011 9:08 pm

Re: CC3000 Failed Connections

by adafruit_support_rick on Sat Oct 26, 2013 11:46 am

I don't know. What happens if you increase the delay to, say, 5 or 10 seconds?
User avatar
adafruit_support_rick
 
Posts: 12102
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: CC3000 Failed Connections

by tinkeringtech on Sat Oct 26, 2013 4:12 pm

I increased the delay and same behavior. I tried a different AP encryption and that did not make a difference. I tried changing the baud to 9600 as well. Could it be related to the SPI bus being flooded or something along those lines?
Its not about brilliance, its all about persistence
www.tinkeringtech.com
tinkeringtech
 
Posts: 52
Joined: Wed Nov 23, 2011 9:08 pm

Re: CC3000 Failed Connections

by adafruit_support_rick on Sun Oct 27, 2013 3:49 am

Seems more like a resource-management issue.

Just to be clear, you get 3 or 4 connections, then it fails once, then starts working again for another 3-4 connections? The output in your first post shows it recovering after a single failure.

Have you tried a different web server? Maybe the one you've been using starts refusing connections for some reason?
User avatar
adafruit_support_rick
 
Posts: 12102
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: CC3000 Failed Connections

by tinkeringtech on Sun Oct 27, 2013 6:30 pm

It is random 3-4 sometimes before failures start occurring. I have posted a log below.
I also tried a different hosting provider to see if there is anything related to the host page thinking that it is a DoS attack or something. Thanks for your help.
Code: Select all | TOGGLE FULL SIZE
Hello, CC3000!
Free RAM: 1238
Initializing...
Started AP/SSID scan

Connecting to wifiAP...Waiting to connect...Connected!
Request DHCP

IP Addr: 192.168.1.11
Netmask: 255.255.255.0
Gateway: 192.168.1.1
DHCPsrv: 192.168.1.1
DNSserv: 192.168.1.1
test.com -> x.x.x.x

Connect to x.x.x.x:80
Inserted data

Connect to x.x.x.x:80
Connection error
Connection failed

Connect to x.x.x.x:80
Connection failed

Connect to x.x.x.x:80
Inserted data

Connect to x.x.x.x:80
Connection error
Connection failed

Connect to x.x.x.x:80
Connection failed

Connect to x.x.x.x:80
Inserted data

Connect to x.x.x.x:80
Inserted data

Connect to x.x.x.x:80
Inserted data

Connect to x.x.x.x:80
Inserted data

Connect to x.x.x.x:80
Inserted data

Connect to x.x.x.x:80
Inserted data

Connect to x.x.x.x:80
Connection error
Connection failed

Connect to x.x.x.x:80
Connection error
Connection failed

Connect to x.x.x.x:80
Connection failed

Connect to x.x.x.x:80
Inserted data

Connect to x.x.x.x:80
Connection failed

Connect to x.x.x.x:80
Inserted data

Connect to x.x.x.x:80
Connection failed

Connect to x.x.x.x:80
Inserted data

Connect to x.x.x.x:80
Connection failed

Connect to x.x.x.x:80
Inserted data

Connect to x.x.x.x:80
Connection failed

Connect to x.x.x.x:80
Inserted data

Connect to x.x.x.x:80
Inserted data
Its not about brilliance, its all about persistence
www.tinkeringtech.com
tinkeringtech
 
Posts: 52
Joined: Wed Nov 23, 2011 9:08 pm

Re: CC3000 Failed Connections

by tinkeringtech on Mon Oct 28, 2013 2:43 pm

Just to add to my post above, could this be a faulty hardware issue? Thanks
Its not about brilliance, its all about persistence
www.tinkeringtech.com
tinkeringtech
 
Posts: 52
Joined: Wed Nov 23, 2011 9:08 pm

Re: CC3000 Failed Connections

by adafruit_support_rick on Mon Oct 28, 2013 7:08 pm

It's not likely to be a hardware issue. If it were, it wouldn't work at all. I've sent a note to one of the library's authors.
User avatar
adafruit_support_rick
 
Posts: 12102
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: CC3000 Failed Connections

by adafruit_support_rick on Tue Oct 29, 2013 7:25 am

I just hacked up the attached sketch from the buildtest example. It does 20 connect/close cycles on the adafruit IP address. It runs here with no failed connections. It does NOT do any of the HTML stuff yours does.

Give it a try with your IP. First, try it as-is (i.e., without the HTML), then add the HTML. See what happens.
Attachments
repeated_connections.zip
(3.09 KiB) Downloaded 23 times
User avatar
adafruit_support_rick
 
Posts: 12102
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: CC3000 Failed Connections

by tinkeringtech on Tue Oct 29, 2013 10:36 pm

Hi Rick,
Something is definitely not right. Its strange that I'm seeing the failures as seen in the log below. This is with the code that you sent me. All I changed was the AP connection information.

Code: Select all | TOGGLE FULL SIZE
Hello, CC3000!

RX Buffer : 131 bytes
TX Buffer : 131 bytes
Free RAM: 1227

Initialising the CC3000 ...
Firmware V. : 1.24
MAC Address : 0x08 0x00 0x33 0x87 0x43 0x67
Started AP/SSID scan

Networks found: 1
================================================
SSID Name    : AP
RSSI         : 43
Security Mode: 1
================================================
Deleting old connection profiles

Attempting to connect to AP
Started AP/SSID scan
Connecting to AP...Waiting to connect...Connected!
Request DHCP

IP Addr: 192.168.1.11
Netmask: 255.255.255.0
Gateway: 192.168.1.1
DHCPsrv: 192.168.1.1
DNSserv: 192.168.1.1
www.adafruit.com -> 207.58.139.247

Pinging 207.58.139.247...3 replies
Ping successful!

Connect to 207.58.139.247:80
Connection error
Connection failed

Connect to 207.58.139.247:80
Connection error
Connection failed

Connect to 207.58.139.247:80
Inserted data

Connect to 207.58.139.247:80
Connection error
Connection failed

Connect to 207.58.139.247:80
Inserted data

Connect to 207.58.139.247:80
Inserted data

Connect to 207.58.139.247:80
Connection error
Connection failed

Connect to 207.58.139.247:80
Connection error
Connection failed

Connect to 207.58.139.247:80
Inserted data

Connect to 207.58.139.247:80
Connection error
Connection failed

Connect to 207.58.139.247:80
Connection error
Connection failed

Connect to 207.58.139.247:80
Connection error
Connection failed

Connect to 207.58.139.247:80
Connection error
Connection failed

Connect to 207.58.139.247:80
Inserted data

Connect to 207.58.139.247:80
Connection error
Connection failed

Connect to 207.58.139.247:80
Connection error
Connection failed

Connect to 207.58.139.247:80
Connection error
Connection failed

Connect to 207.58.139.247:80
Inserted data

Connect to 207.58.139.247:80
Connection error
Connection failed

Connect to 207.58.139.247:80
Connection error
Connection failed
Its not about brilliance, its all about persistence
www.tinkeringtech.com
tinkeringtech
 
Posts: 52
Joined: Wed Nov 23, 2011 9:08 pm

Re: CC3000 Failed Connections

by adafruit_support_rick on Wed Oct 30, 2013 6:42 am

It may be a problem with your access point or router. I'm not sure what else to suggest at this point. Can you take it to a coffee shop or some other access point and see what happens?

The next step would probably to set up Ethereal (formerly known as WireShark), and see if any clues turn up in there.
User avatar
adafruit_support_rick
 
Posts: 12102
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: CC3000 Failed Connections

by herone on Sun May 11, 2014 8:55 am

Hi mates!

I want to make something like that, but I don't know to do this. Would you make a tutorial explaining this?
herone
 
Posts: 41
Joined: Thu Jan 02, 2014 5:27 am