We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Applet crashes with OscP5
Page Index Toggle Pages: 1
Applet crashes with OscP5 (Read 694 times)
Applet crashes with OscP5
Apr 5th, 2010, 8:03am
 
Hey people,

I'm wondering what's going on here...

I've written this totally basic program just to test sending osc messages with an applet. If you click in the applet window, it tries to send an osc message to 127.0.0.1, port 5800 ... and it immediately crashes (the line stops moving). Opening the port (for port-forwarding), using the computer name (tango.local) or specifying the IP address with which it is connected to the network does not solve the problem.

see the crash in action here:
http://www.tarikbarri.nl/osc/

and here's the code:

Code:

import oscP5.*;
import netP5.*;
 
public OscP5 osc;
public NetAddress net;

int y = 0;
void setup()
{
 size(200,200);
 stroke(255);
 osc = new OscP5(this,12000);
 net = new NetAddress("127.0.0.1",5800);
}

void draw()
{
 // moving line, just so you can see clearly when the program crashes (the line stops moving)
 y= (y+2)%height;
 background(0);
 line(0,y,width,y);
}

void mouseClicked()
{
 // after this fatal click the program stops responding... boohoo!
 OscMessage myMessage = new OscMessage( "/PlayEvent" );
 osc.send(myMessage, net);
}


Anybody know what's going on here?

Thanks - Tarik
Re: Applet crashes with OscP5
Reply #1 - Apr 6th, 2010, 2:38am
 
When running an applet, take a look at the Java console. You would see the following stack trace:
Code:
Exception in thread "Animation Thread" java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:5800 connect,resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at sun.plugin2.applet.Applet2SecurityManager.checkConnect(Unknown Source)
at java.net.DatagramSocket.send(Unknown Source)
at netP5.AbstractUdpClient.send(Unknown Source)
at oscP5.OscNetManager.send(Unknown Source)
at oscP5.OscNetManager.send(Unknown Source)
at oscP5.OscP5.send(Unknown Source)
at basicOsc.mouseClicked(basicOsc.java:54)
at processing.core.PApplet.handleMouseEvent(PApplet.java:1614)
at processing.core.PApplet.dequeueMouseEvents(PApplet.java:1544)
at processing.core.PApplet.handleDraw(PApplet.java:1436)
at processing.core.PApplet.run(PApplet.java:1327)
at java.lang.Thread.run(Unknown Source)

That security issue means you have to sign your applet to allow it to do socket operations.
Page Index Toggle Pages: 1