WiFly shield hanging at "if (!WiFly.join(ssid, passphrase)

Hey Guys

I can’t figure out, why wifly shield is not connecting.

It looks like the code does not go past the below loop.

if (!WiFly.join(ssid, passphrase)) {
   Serial.print("ifError");
    while (1) {
      
      Serial.print("Error");
    }
  }

Below is my simple “hello world” webserver code!

#include "WiFly.h"

char passphrase[] = "xxxx-xxxx-xxxx";
char ssid[] = "***** test wireless";

Server server(80);

void setup() {
  
  Serial.begin(9600);
  Serial.println("Setting up");
  WiFly.begin();
  Serial.println("WiFly started");
  
  
if (!WiFly.join(ssid, passphrase)) {
   Serial.print("ifError");
    while (1) {
      
      Serial.print("Error");
    }
  }

 Serial.println("Can u reach me ?");
  Serial.print("IP: ");
  Serial.println(WiFly.ip());
 // myservo.attach(5);
  server.begin();
}

void loop() {
  Client client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean current_line_is_blank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        
        Serial.print(c);
        
        // if we've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so we can send a reply
        if (c == '\n' && current_line_is_blank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          
          client.print("Hello World!");
          
           break;
          
        }
        if (c == '\n') {
          // we're starting a new line
          current_line_is_blank = true;
        } else if (c != '\r') {
          // we've gotten a character on the current line
          current_line_is_blank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(100);
    client.stop();
  }
}

Serial Monitor shows this and nothing else after that :-

Setting up
WiFly started

I checked my wlan auth, wlan phrase, wlan join. All the setting seem to be fine. when I run the “SpiUartTerminal” and save and reboot it connects to WiFly fine! says “associated” !!

wlan auth “open”

wlan join “0”

wlan ssid “right ssid”

wlan phrase “right security key” (cause my wifi modem is set to WPA2)

Please help me fix this problem!!plz plz