0

This is the container I'm trying to connect: enter image description here

And this is the code I have for binding:

public void bindService() {
    Log.i("Bind service:", "Starting");
    serviceConnection = new ServiceConnection() {
        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            microRuntimeService = (MicroRuntimeServiceBinder) service;

            Properties pp = new Properties();
            pp.setProperty(Profile.MAIN_HOST, "192.168.1.5");
            pp.setProperty(Profile.MAIN_PORT, "1099");
            pp.setProperty(Profile.JVM, Profile.ANDROID);
            Log.i("Bind service:", "Properties Set");

            microRuntimeService.startAgentContainer(pp, new RuntimeCallback<Void>() {
                @Override
                public void onSuccess(Void aVoid) {
                    // Split container startup successfull
                    Toast.makeText(MapsActivity.this, "Container created", Toast.LENGTH_LONG).show();
                    Log.i("Bind service:", "Container creation");
                    microRuntimeService.startAgent(nickname, AndroidAgent.class.getName(), new Object[]{getApplicationContext()}, new RuntimeCallback<Void>() {
                        @Override
                        public void onSuccess(Void aVoid) {
                            //Agent succesfully started
                            Toast.makeText(MapsActivity.this, "Agent created", Toast.LENGTH_LONG).show();
                            Log.i("Bind service:", "Success");
                        }

                        @Override
                        public void onFailure(Throwable throwable) {
                            //Agent startup error
                            Toast.makeText(MapsActivity.this, "Agent creation error", Toast.LENGTH_LONG).show();
                            Log.e("Bind service:", "Agent startup error");
                        }
                    });
                }

                @Override
                public void onFailure(Throwable throwable) {
                    // Split container startup error
                    Toast.makeText(MapsActivity.this, "Container failure", Toast.LENGTH_LONG).show();
                    Log.e("Bind service:", "Split container startup error");
                }
            });
            ;
        }

        @Override
        public void onServiceDisconnected(ComponentName name) {
            microRuntimeService = null;
        }
    };
    bindService(new Intent(getApplicationContext(), MicroRuntimeService.class), serviceConnection, Context.BIND_AUTO_CREATE);
    Log.i("Bind service:", "Binding");
}

The code works - I know because my friend used it but in my case my device always falls into this method:

@Override
            public void onFailure(Throwable throwable) {
                // Split container startup error

This is the exception it is showing:

jade.imtp.leap.JICP.BIFEDispatcher: Connection error. java.net.ConnectException: failed to connect to /192.168.1.5 (port 1099): connect failed: ETIMEDOUT (Connection timed out)
09-07 23:06:38.938 19618-20812/com.example.aleksander.localizer E/jade.core.FrontEndContainer: IMTP error jade.core.IMTPException: Error creating the BackEnd.
09-07 23:06:38.940 19618-20812/com.example.aleksander.localizer W/System.err: jade.core.IMTPException: Error creating the BackEnd.
09-07 23:06:38.942 19618-20812/com.example.aleksander.localizer W/System.err:     at jade.imtp.leap.JICP.BIFEDispatcher.createBackEnd(BIFEDispatcher.java:292)
09-07 23:06:38.942 19618-20812/com.example.aleksander.localizer W/System.err:     at jade.imtp.leap.JICP.BIFEDispatcher.getBackEnd(BIFEDispatcher.java:191)
09-07 23:06:38.942 19618-20812/com.example.aleksander.localizer W/System.err:     at jade.core.BackEndWrapper.attach(BackEndWrapper.java:142)
09-07 23:06:38.942 19618-20812/com.example.aleksander.localizer W/System.err:     at jade.core.BackEndWrapper.<init>(BackEndWrapper.java:86)
09-07 23:06:38.943 19618-20812/com.example.aleksander.localizer W/System.err:     at jade.core.FrontEndContainer.start(FrontEndContainer.java:149)
09-07 23:06:38.943 19618-20812/com.example.aleksander.localizer W/System.err:     at jade.core.MicroRuntime.startJADE(MicroRuntime.java:128)
09-07 23:06:38.943 19618-20812/com.example.aleksander.localizer W/System.err:     at jade.android.MicroRuntimeService$1.run(MicroRuntimeService.java:172)
09-07 23:06:38.944 19618-20812/com.example.aleksander.localizer I/jade.android.RuntimeService: Cannot create micro agent container with message: Cannot connect to the platform at 192.168.1.5:1099

Is it something with my router or with my code?
Please help.

Community
  • 1
  • 1
Aleksander Lipka
  • 354
  • 1
  • 9
  • 20
  • This is a network error. Is that the right IP? Its a NAT IP- are you on the same network? Are you on wifi or cell data (should be on wifi to be on the same network)? – Gabe Sechan Sep 07 '16 at 21:30
  • Both my laptop and phone are connected to the same network via wifi. I also tested it with my PC connected via cable to my router. – Aleksander Lipka Sep 07 '16 at 21:35
  • Are the messages getting through? Or is your router acting as a firewall? – Gabe Sechan Sep 07 '16 at 21:36
  • I updated my question with more info from logcat. It seems that my router acts like a firewall or sth: first line shows timeout exception – Aleksander Lipka Sep 07 '16 at 21:38
  • Sounds like it. Luckily most routers will allow you to poke a hole in the firewall for a specific port, so long as you're the router admin. – Gabe Sechan Sep 07 '16 at 21:40
  • I tried to map the port in my router and I also tried to work from the wifi access point created on my phone but with no success – Aleksander Lipka Sep 07 '16 at 22:15
  • Perhaps I'm doing it wrong, on my Huwaei b593 I enter the mapping but my port is still blocked when I check it through this website [link](http://www.yougetsignal.com/tools/open-ports/) :( – Aleksander Lipka Sep 07 '16 at 22:27

0 Answers0