UDP print method locks up program

I trying to get my Arduino UNO with W5100 Ethernet shield to send data to an Influx database. That’s all the 'duino is programmed to do at the moment. I created my code based on an example on the Influx website. Problem is that the Arduino hangs when executing the udp.print() method.

This is the code I have:

#include <SPI.h>
#include <Ethernet.h>

byte influxServer[] = { 192, 168, 0, 250 };
int influxPort = 8089;

unsigned long prevLongCycle = 0L;
unsigned long prevShortCycle = 0L;
unsigned long loopCounter = 0L;

const int SD_CS = 4;
const int WIZ_CS = 10;

EthernetUDP udp;

// Arduino init loop
void setup()

    // Disable SD to avoid interference with ethernet chip
    pinMode(SD_CS, OUTPUT);
    digitalWrite(SD_CS, HIGH);
    // Init Wiznet W5100
    if (Ethernet.linkStatus() == LinkOFF) {
        Serial.println("Ethernet cable is not connected.");

    byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
    if (Ethernet.begin(mac, 10000UL, 10000UL) == 1) {
        Serial.println(F("DHCP OK"));
    else {
        Serial.println(F("DHCP Failed"));

void loop()
    unsigned long now = millis();

    // 30 second interval cycle
    if (now - prevLongCycle >= 30000) {
        // Format: <measurement> <sensor>=<value>,<sensor>=<value>,......
        String payload = "test ";
        PayloadBuilder(payload, "current", now, true);
        PayloadBuilder(payload, "previous", prevLongCycle);
        SendToInflux(payload, influxServer, influxPort);
        prevLongCycle = now;

// UDP payload builder
void PayloadBuilder(String &payload, String sensor, double value, bool firstItem = false) {
    if (firstItem) { 
        payload += sensor + "=" + String(value);
    else {
        payload += "," + sensor + "=" + String(value);

// Push data to Influx DB
void SendToInflux(String data, byte host[], int port) {
    Serial.println("Influx payload: " + data);

    uint8_t res = 0;
    // Begin packet
    res = udp.beginPacket(host, port);
    if(res == 0) { Serial.println("Error starting UDP packet"); }
    res = udp.endPacket();
    if (res == 0) { Serial.println("Error ending UDP packet"); }
    Serial.println("Payload push complete");

When I load this into the Arduino, after 30 seconds it will execute the SendToInflush() method which is the last thing it’ll do. I tried figuring out where things go wrong but cannot find the culprit.
I tried the same code pointing to different influx servers (have one on Windows and on on Linux for testing), but they all do the same thing. Influx itself does not report anything, not even a connection attempt.
It almost looks like the library is not compatible with the shield or something. It is an older V1 shield, but is has always worked fine.
Both influx server have been configured with no authorization and to accept UDP connections on port 8089.

Post the serial output you got!

You shouldn't use the String class on AVR based Arduinos! It fragments your memory too fast and then you get unpredictable behavior.