oscP5 Android cannot send, only receive

edited January 2014 in Android Mode

hi all,

i have an Android sketch sending to an sketch in Java mode (running on my pc) i can receive messages on my android client, but not send any message to the pc server ???... (it works well when both run in Java Mode) NetInfo.print() tells me that the Server has the real IP, but the Android (running on my Phone) says "INFO @ OscP5 is running. you (127.0.0.1) are listening @ port 5002" and not its Wifi IP (does this matter?)

I tried out many possibilities, no success :-( ... Please help, thanks!

here is the send part / summarized

OscP5 oscP5; NetAddress myRemoteLocation; OscMessage myMessage;

void setup() { oscP5 = new OscP5(this, incoming_port); myRemoteLocation = new NetAddress(remote_ip,remote_port); }

void mousePressed(){

// create an osc message OscMessage myMessage = new OscMessage("//"); myMessage.add("Message:"+id); // add a string to the osc messag

try{ //myRemoteLocation = new NetAddress(remote_ip,remote_port); oscP5.send(myMessage, myRemoteLocation); //oscP5.flush(myMessage, myRemoteLocation); msg_out=myMessage.get(0).stringValue(); println(msg_out); id++; }catch(Exception e){ msg_out="Error: " + e.getMessage(); println(msg_out); } }

console Output (Android Client, not connected to internet) debug:

hostname/ip localhost/127.0.0.1

hostname localhost

ip 127.0.0.1

[2014/1/21 15:0:18] PROCESS @ NetInfo.checkNetworkStatus : 127.0.0.1

[2014/1/21 15:0:18] PROCESS @ NetInfo.checkNetworkStatus Checking internet connection ...

[2014/1/21 15:0:38] ERROR @ NetInfo.checkNetworkStatus ! Unable to open http://checkip.dyndns.org

Either the http://checkip.dyndns.org is unavailable or this machine is notconnected to the internet ! OscP5 0.9.9 infos, comments, questions at http://www.sojamo.de/oscP5 Register Dispose java.lang.NullPointerException

[2014/1/21 15:0:38] PROCESS @ OscP5 stopped.

[2014/1/21 15:0:38] PROCESS @ UdpClient.openSocket udp socket initialized.

[2014/1/21 15:0:39] PROCESS @ UdpServer.start() new Unicast DatagramSocket created @ port 5002

[2014/1/21 15:0:39] INFO @ OscP5 is running. you (127.0.0.1) are listening @ port 5002

[2014/1/21 15:0:39] PROCESS @ UdpServer.run() UdpServer is running @ 5002

Inefficient font rendering: use createFont() with a TTF/OTF instead of loadFont().

Tagged:

Answers

  • ** Sorry, now with better formatting **

    import oscP5.*;
    import netP5.*;
    
    OscP5 oscP5;
    NetAddress myRemoteLocation;
    OscMessage myMessage;
    
    (...) 
    
    void setup()
    {
      NetInfo.print();
    
      // start oscP5, telling it to listen for incoming messages at incoming_port
      oscP5 = new OscP5(this, incoming_port);
      //set the remote location 
      myRemoteLocation = new NetAddress(remote_ip,remote_port);
    
     (...)
    
    }
    
    void draw() {
      (...)
    } 
    
    void mousePressed(){
    
      // create an osc message
      OscMessage myMessage = new OscMessage("//");
      myMessage.add("Message:"+id); // add a string to the osc messag
    
      try{
    
        oscP5.send(myMessage, myRemoteLocation); 
    
      }catch(Exception e){ 
        msg_out="Error: " + e.getMessage();
        println(msg_out);
      }
    }
    
    void oscEvent(OscMessage theOscMessage) 
    {
      msg_in = theOscMessage.get(0).stringValue();
    }
    

    ** Console **

    debug:
    ### hostname/ip localhost/127.0.0.1
    ### hostname localhost
    ### ip 127.0.0.1
    ### [2014/1/21 15:0:18] PROCESS @ NetInfo.checkNetworkStatus :  127.0.0.1
    ### [2014/1/21 15:0:18] PROCESS @ NetInfo.checkNetworkStatus Checking internet  connection ...
    ### [2014/1/21 15:0:38] ERROR @ NetInfo.checkNetworkStatus ! Unable to open  http://checkip.dyndns.org
    Either the  http://checkip.dyndns.org is unavailable or this machine  is notconnected to the internet !
    OscP5 0.9.9 infos, comments, questions at http://www.sojamo.de/oscP5
    Register Dispose
    java.lang.NullPointerException
    ### [2014/1/21 15:0:38] PROCESS @ OscP5 stopped.
    ### [2014/1/21 15:0:38] PROCESS @ UdpClient.openSocket udp socket initialized.
    ### [2014/1/21 15:0:39] PROCESS @ UdpServer.start() new Unicast DatagramSocket created @ port 5002
    ### [2014/1/21 15:0:39] INFO @ OscP5 is running. you (127.0.0.1) are listening @ port 5002
    ### [2014/1/21 15:0:39] PROCESS @ UdpServer.run() UdpServer is running @ 5002
    
  • it must be a networking issue, because the code works (when sending the message to itself/127.0.0.1, it receives it properly)

  • A generic answer: Do you have the INTERNET permission enabled for the Android sketch (Android > Sketch Permissions from the PDE)?

  • yes of course :-); nevertheless, i found a work around -> using instead the UDP Library, it seems to work. Reason - maybe when creating a new udp object, you can set your (real) ip adress => udp = new UDP(this, incoming_port, own_ip);

  • But i would really prefer to use oscP5 ... any ideas?

Sign In or Register to comment.