juce-framework / JUCE

JUCE is an open-source cross-platform C++ application framework for desktop and mobile applications, including VST, VST3, AU, AUv3, LV2 and AAX audio plug-ins.
https://juce.com
Other
6.63k stars 1.75k forks source link

OSC blobs are lost above 4076 bytes of size #141

Closed harry-g closed 7 years ago

harry-g commented 7 years ago

When sending OSC blobs with size above 4076 bytes, nothing is received on the other end, at least in Windows 10 x64. It can easily be reproduced.

Test case:

#include "../JuceLibraryCode/JuceHeader.h"

// start size ob blobs sent via OSC - increasing every 10 times
#define START_TEST_SIZE_BYTES 4070

class TestOSC : public JUCEApplication, OSCReceiver, OSCReceiver::Listener<>, Timer {
public:
    TestOSC() {
        // connect OSC sender&receiver
        jassert(sender.connect("127.0.0.1", 9002));
        jassert(connect(9002));
        // listen for OSC messages
        addListener(this);

        // initial size
        data.ensureSize(size);
        // sender timer
        startTimerHz(10);
    }

private:
    MemoryBlock data;
    OSCSender sender;
    int32 size = START_TEST_SIZE_BYTES, counterSender = 0, counterReceiver = 0, counterBlob = 0;

    virtual void timerCallback() override
    {
        // send counter and blob
        sender.send("/test/counter", ++counterSender);
        jassert(sender.send("/test/data", data));

        // after 10 Blobs, increase size by 1
        if (!(counterSender % 10))
            data.ensureSize(++size);
    }

    void oscMessageReceived(const OSCMessage& message) override
    {
        jassert(message.size() == 1);
        String address = message.getAddressPattern().toString();
        // receive counter
        if (message[0].isInt32()) {
            Logger::outputDebugString("Received counter: " + address + " - value: " + String(counterSender));
            // before evaluating next counter, check if corresponding blob was already received
            if (counterBlob != counterReceiver)
                // THIS IS THE BUG I WANT TO SHOW
                Logger::outputDebugString("ERROR: missing blobs are " + String(counterReceiver - counterBlob));
            // store recieved counter
            counterReceiver = message[0].getInt32();
        // receive blob
        } else if (message[0].isBlob()) {
            int32 messageSize = message[0].getBlob().getSize();
            Logger::outputDebugString("Received blob   : " + address + "    - size: " + String(messageSize));
            // count received blobs
            counterBlob++;
        } else
            jassert(false);
    }

    // Inherited via JUCEApplication - not needed here
    virtual const String getApplicationName() override { return String(); }
    virtual const String getApplicationVersion() override { return String(); }
    virtual void initialise(const String & commandLineParameters) override {}
    virtual void shutdown() override {}
};

START_JUCE_APPLICATION(TestOSC)
harry-g commented 7 years ago

If this does not fail on other machines/OSes, you can try to increase the start size or increase with every send instead of every 10.

BruceWheaton commented 7 years ago

As a primarily UDP based protocol, this is probably expected behavior. If a blob size limit isn't in the protocol it probably should be.

Bruce

On Dec 12, 2016, at 03:41, harry-g notifications@github.com wrote:

If this does not fail on other machines/OSes, you can try to increase the start size or increase with every send instead of every 10.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

harry-g commented 7 years ago

Yeah sorry, I was not researching it fully, I thought of the 64k limit in the protocol but in fact, practical infrastructure can limit it to 512 bytes. See also parallel discussion in forum: https://forum.juce.com/t/osc-blobs-are-lost-above-certain-size/20241

Closing this one...