Open knupel opened 7 years ago
Just in case I update the sketch test for the big message:
sometime there is an IndexOutbound... blablah, sometime your error message message too long
and the difference of length between them is huge.
/**
* oscP5message by andreas schlegel
* example shows how to create osc messages.
* oscP5 website at http://www.sojamo.de/oscP5
*/
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
// OscP5 osc_receive_controller ;
void setup() {
size(400,400);
/* start oscP5, listening for incoming messages at port 12000 */
int port = 10_000 ;
oscP5 = new OscP5(this,port);
myRemoteLocation = new NetAddress("127.0.0.1",port);
}
void draw() {
background(0);
send() ;
}
int count_send = 0 ;
float bool_unit = 1. ;
float misc_unit = 5. ;
float string_unit = 6.1 ;
void send() {
count_send++ ;
OscMessage myMessage = new OscMessage("test");
/*
string_limit = string_limit + "a" ;
myMessage.add(string_limit); // add an int to the osc message
println("String limit", string_limit.length()) ;
*/
/**
Array int limit 306
String limit 1524
java.lang.ArrayIndexOutOfBoundsException
*/
/**
Parfois va jusqu'à cette limite quand la ligne oscP5.send() a été mis en commentaire puis réactivée.... bizarre
array limit 1842
String limit 9204
Could not send datagram java.net.SocketException: Message too long
*/
// byte_limit(myMessage) ; // 1842 or 305
boolean_limit(myMessage) ; // 9207 no IndexOout for this time
// int_limit(myMessage); // 1842 or 305
// float_limit(myMessage); // 1842 or 305
// char_limit(myMessage); // 1842 or 305
// string_limit(myMessage); // 9204 or 1524
// string_limit_unit(myMessage); // 1842 or 305
// object_limit(myMessage); // 1842 or 305
/* send the message */
oscP5.send(myMessage, myRemoteLocation);
}
String string_limit =("");
void string_limit(OscMessage myMessage) {
string_limit += "a" ;
myMessage.add(string_limit); // add an int to the osc message
println("String limit", string_limit.length()) ;
}
void string_limit_unit(OscMessage myMessage) {
String [] array_string = new String [count_send];
for(int i = 0 ; i < count_send ; i++) {
array_string[i] = "a" ;
myMessage.add(array_string[i]); // add an int to the osc message
}
println("String limit", array_string.length) ;
}
void object_limit(OscMessage myMessage) {
Object [] array_obj = new Object[count_send] ;
for(int i = 0 ; i < count_send ; i++) {
array_obj[i] = i ;
myMessage.add(array_obj[i]); // add an int to the osc message
}
println("Array object limit", array_obj.length) ;
}
void char_limit(OscMessage myMessage) {
char [] array_char = new char[count_send] ;
for(int i = 0 ; i < count_send ; i++) {
array_char[i] = 'e' ;
myMessage.add(array_char[i]); // add an int to the osc message
}
println("Array char limit", array_char.length) ;
}
void float_limit(OscMessage myMessage) {
float [] array_float = new float[count_send] ;
for(int i = 0 ; i < count_send ; i++) {
array_float[i] = i ;
myMessage.add(array_float[i]); // add an int to the osc message
}
println("Array float limit", array_float.length) ;
}
void int_limit(OscMessage myMessage) {
int [] array_int = new int[count_send] ;
for(int i = 0 ; i < count_send ; i++) {
array_int[i] = i ;
myMessage.add(array_int[i]); // add an int to the osc message
}
println("Array int limit", array_int.length) ;
}
void boolean_limit(OscMessage myMessage) {
boolean [] bool_limit = new boolean[count_send];
for(int i = 0 ; i < bool_limit.length ; i++) {
bool_limit[i] = true ;
myMessage.add(bool_limit[i]); // add an int to the osc message
}
println("Boolean limit", bool_limit.length);
}
void byte_limit(OscMessage myMessage) {
byte [] byte_limit = new byte[count_send];
for(int i = 0 ; i < byte_limit.length ; i++) {
byte_limit[i] = '1' ;
myMessage.add(byte_limit[i]); // add an int to the osc message
}
println("Byte limit", byte_limit.length);
}
I was looking for the same issue (not for sender but for receiver) and I figured out that you need OscProperties::setDatagramSize
like
void setup() {
size(400, 400);
/* start oscP5, listening for incoming messages at port 12000 */
int port = 10_000 ;
OscProperties op = new OscProperties();
op.setListeningPort(10000);
op.setDatagramSize(5000);
oscP5 = new OscP5(this, op);
myRemoteLocation = new NetAddress("127.0.0.1", port);
}
to increase the data size, for example, to 5,000. Note that data includes osc address and other metadata (?) so you can send a bit less than 5,000 characters in this case.
Thx @micuat for the trick, now I can push to the limit of the datagram, 1842 for the classic array type like int, float, String...
the limit is
op.setDatagramSize(9220); // 9220 is the max to push to the datagram limit
For those that might run into Index Out Of Bounds errors when trying to parse incoming messages. The reason could be that the type is one that needs a larger datagram size. I ran into it when trying to parse messages from the Moss OSC controller script for Bitwig, probably caused by the {color}
type being send by messages such as /vkb_midi/note/{0-127}/color
The fix above posted by @micuat solves that error in oscP5
Hello, I try to send message, but I found a different limit for each type of argument. That's depend of my computer or it's a limit of the OSC ? It(s possible to increase this limit ? Or don't stop Processing and just limit the the size of the package must be sent and print a warning to inform the user ?
and thx for your work.
Processing 3.3.4 OS Sierra Osc 2.0.4
String limit 1524 java.lang.ArrayIndexOutOfBoundsException
Array float limit 1842 Could not send datagram java.net.SocketException: Message too long
Array int limit 306 java.lang.ArrayIndexOutOfBoundsException
Boolean limit 9207 Could not send datagram java.net.SocketException: Message too long
Here the little sketch I code to find the limit.