MKR100 can't connect to my own mqtt server, socket error.

I have installed a mosquitto server mosquitto version 1.4.10 (build date Thu, 25 Aug 2016 10:12:09 +0100) and I’m trying to connect to it using the MKR1000 rev2.

// This example uses an Arduino/Genuino Zero together with
// a WiFi101 Shield or a MKR1000 to connect to shiftr.io.
//
// IMPORTANT: This example uses the new WiFi101 library.
//
// You can check on your device after a successful
// connection here: https://shiftr.io/try.
//
// by Gilberto Conti
// https://github.com/256dpi/arduino-mqtt

#include <SPI.h>
#include <WiFi101.h>
#include <MQTTClient.h>

char *ssid = "ssid";
char *pass = "pass";

WiFiClient net;
MQTTClient client;

unsigned long lastMillis = 0;

void setup() {
  Serial.begin(9600);
  WiFi.begin(ssid, pass);
  client.begin("mqtt.my_server.ro", net);

  connect();
}

void connect() {
  Serial.print("checking wifi...");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(1000);
  }

  Serial.print("\nconnecting...");
  int err = 0;
  while (! (err = client.connect("arduino", "try", "try")) ) {
    Serial.println(err);
    delay(1000);
  }

  Serial.println("\nconnected!");

  client.subscribe("/example");
  // client.unsubscribe("/example");
}

void loop() {
  client.loop();

  if(!client.connected()) {
    connect();
  }

  // publish a message roughly every second.
  if(millis() - lastMillis > 1000) {
    lastMillis = millis();
    client.publish("/hello", "world");
  }
}

void messageReceived(String topic, String payload, char * bytes, unsigned int length) {
  Serial.print("incoming: ");
  Serial.print(topic);
  Serial.print(" - ");
  Serial.print(payload);
  Serial.println();
}

When I try to run this code I get the following messages in the server logs:

1483048841: New connection from x.x.x.x on port 1883.
1483048841: Socket error on client , disconnecting.

I could successfully connect to the server using Python with pacho or the cli commands: mosquitto_sub, mosquitto_pub

I've tried to use multiple MQTT libraries but I get the same result. Wifi101 is version 0.11.2