WiFi client Does not work. HTTPClient does.

I tried this with multiple hosts and get 0 for connect status. I even opened up a New ESP8266 and same darn thing happens, so it’s gotta be the code or the lib itself. I haven’t heard of WiFiClient lib having such a serious bug though.

I just re-downloaded WiFiClient.cpp and WiFiClient.h and it still does NOT connect… I get"Connect status 0,connection failed


#include <SPI.h>
#include <WiFiClient.h>
#include <Arduino.h>
#include <ESP8266WiFi.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 23 is default for telnet;
// if you're using Processing's ChatServer, use port 10002):
WiFiClient client;
IPAddress ip(192, 168, 1, 139);
IPAddress server(192,168,1,71);
void setup() {
  IPAddress gw(192, 168, 1, 254);
  IPAddress dns(192, 168, 1, 254);
  IPAddress sn(255, 255, 255, 0);
  WiFi.config(ip, gw, sn,  dns);
  WiFi.begin("JMR", "HIDDEN");

  // Open serial communications and wait for port to open:

  // if you get a connection, report back via serial:
  int x = client.connect(server, 15080);
 Serial.printf("Connect status %d,",x);
  if (x) {
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");

void loop() {
  // if there are incoming bytes available
  // from the server, read them and print them:
  if (client.available()) {
    char c = client.read();

  // as long as there are bytes in the serial queue,
  // read them and send them out the socket if it's open:
  while (Serial.available() > 0) {
    char inChar = Serial.read();
    if (client.connected()) {

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    // do nothing:
    while (true) {

you don't wait until WiFi connects.