'No socket available' error with Arduino WiFi Shield.

I am currently working on a project where Arduino with the WiFi Shield tweets sensor readings but once it has read the sensor and tweeted the reading it enters in a continuous loop saying that it can´t connect because there is ‘no socket available’ so that doesn´t help me with my project. The code itself is the following:

#include <WiFi.h>
#include <Twitter.h>
#include "DHT.h"

DHT dht;

char ssid[] = "WIFISSID";
char pass[] = "WIFIPASSWD"; 

// Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
Twitter twitter("TOKEN");

char buffer [14];
float temperature;

void setup() {
  dht.setup(2); //DHT´s pin is 2
  //strcat("This is temp", buffer);
  WiFi.begin(ssid, pass);
  // or you can use DHCP for automatic IP address configuration.
  // WiFi.begin(mac);

void loop () {
  temperature = dht.getTemperature();
  dtostrf(temperature, 2, 1, buffer);
  Serial.println("connecting ...");
  if (twitter.post (strcat("La temperatura actual es ", buffer))) {
    int status = twitter.wait(&Serial);
    if (status == 200) {
    } else {
      Serial.print("failed : code ");
  } else {
    Serial.println("connection failed.");

The error prompted by the Serial Monitor is this one:

connecting ...
HTTP/1.0 200 OK
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Vary: Accept-Encoding
Date: Sat, 24 Aug 2013 20:17:36 GMT
Server: Google Frontend
Alternate-Protocol: 80:quic


connecting ...
No Socket available
connection failed.

As I have found out the problem is due to a disconnection from the WiFi Network by the WiFi Shield that is why it founds ‘no socket available’, but I have no clue on how to solve this. Thank you for your effort.

I’m not absolute about this, but your code seem to be lacking the connection routine, Well that what i can see comparing with the tweeter example you seem to use to elaborate your programe with

void connectToServer() {
  // attempt to connect, and wait a millisecond:
  Serial.println("connecting to server...");                   
  if (client.connect(server, 80)) {                       // <----------Here
     Serial.println("making HTTP request...");
    // make HTTP GET request to twitter:
    client.println("GET /1/statuses/user_timeline.xml?screen_name=arduino HTTP/1.1");
    client.println("Host: api.twitter.com");
    client.println("Connection: close");
  // note the time of this connect attempt:
  lastAttemptTime = millis();

I couldn´t do anything with it, I didn´t use that example it´s the one that comes with the WiFi Library. I used a variation that comes with the Twitter Library (for WiFi) and then modified it to supply my needs.

Still receiving the 'No socket available' error.

Wait, Last week there was some guy who also had a similar problem with his wifi shield. I don’t know if it will help but he resolved his problem by using the version 1.0.3 version of the IDE.

Try that for the fun of it

Unluckily nothing happened, I´ve also tried with the 1.0.2 version (They also said it´ll fix this) and none of them did anything. Now it´s for sure it is a coding problem. Solution? (I wish I knew it haha)

Thanks for the tip Frédéric_Plante

Personally, I use WiFi 2 Serial module.

The connection procedure seem to be obvious. So if it's not IDE nor the connect routine, I'm gonna have to follow this post to see if i'm not gonna learn some thing new. :wink: