Languages

Menu
Sites
Language
message_port_send_message( ) returning error: "-5"

Hi,

I have created a hybrid app and want a communication between webapp and a service native app. I am following this link for reference: https://developer.tizen.org/dev-guide/2.3.0/org.tizen.mobile.native.appprogramming/html/tutorials/app_tutorial/message_port_tutorial.htm#uni 

I have registered the local port in webapp and waiting for receiving data from service app. In service app, I have first checked the availability of port using  

message_port_check_remote_port (x, y, &z)

 where I have given "x" as my webapp id and "y" as local port of webapp  and "z" is coming out to be "true" which means that it has found the corresponding port. 

Now subsequently when I try to send a message using 

message_port_send_message(x, y, bundle)

 with x and y same as before and passing bundle which I've created, I get an error of "-5". What does it signify ? Where I am going wrong ? Can someone help me on this ?

EDIT: I figured out that the error is "MESSAGE_PORT_ERROR_IO_ERROR". What possibly can be the cause of this ?

Thanks.

Edited by: Dheeraj Khoriya on 21 Mar, 2015

Responses

7 Replies
colin Rao

Is it possible that you implement in a wrong way. As the reference link, seems that you should register the local port in the native service app, but not in the webapp.

In other words, the service app should be considered as a server, it should register a local port and waiting for the connection request and/or messages which sent from the client, here is the webapp.

Dheeraj Khoriya

Yes Colin,

You are right. The local port needs to be registered in service app. 

With everything same as what I mentioned in my problem together with what you said about registering the local port in service makes the problem go away. 

Though I have other problem now- now that the service is alltime running and I am able to receive message from service to my webapp, I want to trigger the service at given time interval periodically (trigger here implies that service which is running in the background needs to do the specific job at times requested by webapp). In my case: I want the service to fetch data from internet (I am able to do that using CURL) and send it to webapp. Can you help in this too ?

Thanks a lot for previous clarification.

Alex Ashirov

Hi,

You need to use Bi-directional Message Port Communication. The Bi-directional Message Port Communication is also described in the Tutorial mentioned by you above.

Briefly, you need to pass local message port of web app as parameter of sendMessage() method from your web application. In this case, this local port (of web app) will be passed as remote port parameter of service app’s callback. So, you will be able to use this remote port param to send response to web app from service app.

Alex Ashirov

Hi,

BTW, It seems that you did everything right in your first message of this topic. As far as I understand you just tried to send message from service app to web app unidirectional. If so, then why do you need register local message port on the service app side?

colin Rao

Please check the "Using Bi-directional Message Port Communication" section in your pasted link(https://developer.tizen.org/dev-guide/2.3.0/org.tizen.mobile.native.appprogramming/html/tutorials/app_tutorial/message_port_tutorial.htm#uni) to implement message send between webapp with service app.

Another, did you means you don't want the service auto start and running always in background? If true,

first, config the service to not auto-restart, and not start on-boot in manifist xml file, 

<service-application component-type="svcapp" auto-restart="false" on-boot="false"

second, use app control api to launch & terminate the service while you need the service app to fetch data for your webapp. 

 

Alex Ashirov

Hi,

BTW, one more note. If you use the same author certificate for the both web and native apps then it’s better to use the Trusted message port communication.  In this case only applications signed with the same certificate can communicate with each other. So, any other 3rd party apps will not be able to use your message ports.

Dheeraj Khoriya

Yes, thanks for the info. I will use once I have all my problems resolved.