Processing on Raspberry Pi thinks its IP address is 127.0.1.1

I installed Processing 3.0.1 on my Raspberry Pi2 (running Raspian Jamie) and have run into issues with the processing.net library and with oscp5. When I use either library and print the IP address to the console (via Server.ip() or NetInfo.lan() respectively) the response is 127.0.1.1 but the WAN is showing the correct WAN IP address. I've tried with both Ethernet and USB wifi network adapters. Any ideas of how I can configure this to report the correct IP and active network adapter? Is this likely and issue with the libraries, Processing, Raspian, or the Pi? Thank you for any ideas!

Answers

  • Thanks Ater! I ran the same code on my windows laptop and got my local IP instead of the Localhost or Loop Back address. Any ideas about how I can convince Processing on the Pi to use one of the active adapters eth0 or preferably wlan0 instead? They're active and working for we browsing, vnc, and report out when I run ifconfig. Thank you for any ideas about this, and apologies if the answer is on the wikipedia page and I didn't understand.

  • edited February 2016

    I made a little progress on this. I poked around in the oscP5 library code and pulled out a section that seemed to scan all available network interfaces. When I ran this as its own sketch I got a report out about my wlan (wifi), the loopback/localhost, and the ethernet connection!

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.net.InetAddress;
    import java.net.MalformedURLException;
    import java.net.NetworkInterface;
    import java.net.SocketException;
    import java.net.URL;
    import java.util.Collections;
    import java.util.Enumeration;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.StringTokenizer;
    import java.util.logging.Logger;
      
      Map< String , Map > m = new HashMap< String , Map >( );
      Enumeration< NetworkInterface > nets;
        try {
          nets = NetworkInterface.getNetworkInterfaces( );
          for ( NetworkInterface netint : Collections.list( nets ) ) {
            Map< String , Object > m1 = new HashMap< String , Object >( );
            m.put( netint.getDisplayName( ) , m1 );
            m1.put( "name" , netint.getName( ) );
            m1.put( "display-name" , netint.getDisplayName( ) );
            m1.put( "mac" , netint.getHardwareAddress( ) );
            m1.put( "network-interface" , netint );
            Enumeration< InetAddress > inetAddresses = netint.getInetAddresses( );
            for ( InetAddress inetAddress : Collections.list( inetAddresses ) ) {
              m1.put( "inet-address" , inetAddress );
            }
    
          }
        } catch ( SocketException e ) {
          e.printStackTrace( );
        }
        
        println(m);
    
    

    When I ran that I got this result in the console:

    {
      wlan0={
        inet-address=/192.168.86.106, 
        display-name=wlan0, 
        network-interface=name:wlan0 (wlan0), 
        name=wlan0, 
        mac=[B@5e624e}, 
        lo={
            inet-address=/127.0.0.1, 
            display-name=lo, 
            network-interface=name:lo (lo), 
            name=lo, 
            mac=null
        }, 
        eth0={
            inet-address=/192.168.1.77, 
            display-name=eth0,
            network-interface=name:eth0 (eth0), 
            name=eth0, 
            mac=[B@192c425}
        }
    

    I think I just need to convince oscP5 and netP5 to use my wlan instead of the loopback/local host as the primary connection.

  • No luck so far working with the oscP5 and netP5 libraries, but I did try a really basic networking example which worked. The "Example 2: Shared Drawing Canvas" from https://processing.org/tutorials/network/ works great! Not only can the Raspberry Pi connect to other devices on my network (as the OSC examples had) but my windows machine could communicate with the Pi too even if the Pi was the server not the client.

    I can use this example for my immediate purposes, but I'm still very interested to know if oscP5 can be adapted to work properly on the Pi or if I need to configure something to do so.

Sign In or Register to comment.