Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moquette keeps on crashing app #338

Closed
blaine12100 opened this issue Jul 19, 2017 · 6 comments

Comments

@blaine12100
Copy link

commented Jul 19, 2017

I'm trying to use moquette for an app but as soon as i launch the app,it keeps on crashing the app without showing any error.If anyone can help me i'd be highly grateful.

Error Logcat
07-19 13:53:47.053 21991-21991/com.example.dhruvmarwha.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.dhruvmarwha.myapplication, PID: 21991
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.dhruvmarwha.myapplication/com.example.dhruvmarwha.myapplication.MainActivity}: io.moquette.proto.MQTTException: Can't create temp file for subscriptions storage [//moquette_store.mapdb]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6540)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: io.moquette.proto.MQTTException: Can't create temp file for subscriptions storage [//moquette_store.mapdb]
at io.moquette.spi.persistence.MapDBPersistentStore.initStore(MapDBPersistentStore.java:95)
at io.moquette.spi.impl.SimpleMessaging.init(SimpleMessaging.java:86)
at io.moquette.server.Server.startServer(Server.java:125)
at io.moquette.server.Server.startServer(Server.java:110)
at io.moquette.server.Server.startServer(Server.java:102)
at io.moquette.server.Server.startServer(Server.java:72)
at com.example.dhruvmarwha.myapplication.MainActivity.onCreate(MainActivity.java:113)
at android.app.Activity.performCreate(Activity.java:6980)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6540) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 
Caused by: java.io.IOException: Read-only file system
at java.io.UnixFileSystem.createFileExclusively0(Native Method)
at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:281)
at java.io.File.createNewFile(File.java:1000)
at io.moquette.spi.persistence.MapDBPersistentStore.initStore(MapDBPersistentStore.java:91)
at io.moquette.spi.impl.SimpleMessaging.init(SimpleMessaging.java:86) 
at io.moquette.server.Server.startServer(Server.java:125) 
at io.moquette.server.Server.startServer(Server.java:110) 
at io.moquette.server.Server.startServer(Server.java:102) 
at io.moquette.server.Server.startServer(Server.java:72) 
at com.example.dhruvmarwha.myapplication.MainActivity.onCreate(MainActivity.java:113) 
at android.app.Activity.performCreate(Activity.java:6980) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6540) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 

@andsel

This comment has been minimized.

Copy link
Collaborator

commented Jul 19, 2017

"Can't create temp file for subscriptions storage" says to you that your app (which is embedding Moquette) can't write the file //moquette_store.mapdb, I think that some libraries used by Moquette are not supported by Android

@andsel andsel closed this Jul 19, 2017

@blaine12100

This comment has been minimized.

Copy link
Author

commented Jul 19, 2017

So it's not possible to create a local broker onto an android machine then?

i am trying this syntax new Server.startserver() uisng
MemoryConfig memoryConfig = new MemoryConfig(new Properties());
memoryConfig.setProperty(BrokerConstants.PERSISTENT_STORE_PROPERTY_NAME, Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + BrokerConstants.DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME);

However,in my app,it's unable to connect to "tcp://localhost:1883".Any Idea?

@andsel

This comment has been minimized.

Copy link
Collaborator

commented Jul 19, 2017

Officially the Moquette doesn't support Android but just JVM (J2SE 1.8 and above), I've never tried it on Dalvik. But which would you like to run broker on Android instead of the client?

@pas6vite

This comment has been minimized.

Copy link

commented Aug 31, 2017

Hi blaine12100
Don't worry Moquette works on Android
I got the same exception today when I tried to use moquette into my Android project.
To solve the issue I did the following changes:

@blaine12100

This comment has been minimized.

Copy link
Author

commented Sep 1, 2017

@surveshoeb

This comment has been minimized.

Copy link

commented Dec 14, 2018

Kindly use following code

if (PermissionChecker.checkSelfPermission(getApplicationContext(), permissions[0]) == PermissionChecker.PERMISSION_GRANTED) {
            MemoryConfig memoryConfig = new MemoryConfig(new Properties());
            memoryConfig.setProperty(BrokerConstants.PERSISTENT_STORE_PROPERTY_NAME,
                    Environment.getExternalStorageDirectory().getAbsolutePath()+
                            File.separator + BrokerConstants.DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME);

            server.startServer(memoryConfig);
}
else
    ActivityCompat.requestPermissions(this, permissions, REQUEST_CODE);

and don't forget to add following line in your manifest.xml
<service android:name="org.eclipse.paho.android.service.MqttService" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.