Languages

Menu
Sites
Language
Unable to connect to localhost:port using XMLHttpRequest

Hi,

 We are getting an error when we try to establish a connection to localhost through XMLHttpRequest . Below is the usecase

 we are developing a hybrid application. In native app we have a server running (localhost:port) and based on the html request from web app using XMLHttpRequest  it will serve the content. But looks like an error is happenning.  We have given below permissions

 

    tizen:privilege name=internet (removed complete url as external links are blocked)

    access origin="*" subdomains="true"

 Observations : 

[x] Connection is success for other urls. (google)

[x] We are able to connect to the localhost server from the native application using curl

[x] When the error is observed connection is not even landed on the server. Even before that libsoup/Webkit is rejecting the process

 

Please help if we are missing something

 

We are getting below errors during the process

 04-02 16:35:03.536 : DEBUG / libsoup ( 2990 : 2990 ) : soup-message.c: soup_message_finished(1277) > msg[0x9bc0010] status_code[4] reason[Cannot connect to destination (127.0.0.1)]
04-02 16:35:03.536 : DEBUG / libsoup ( 2990 : 2990 ) : soup-message.c: soup_message_finished(1278) > [SECURE_LOG] msg[0x9bc0010] url[127.0.0.1:60223/index.html] status_code[4] reason[Cannot connect to destination (127.0.0.1)]
04-02 16:35:03.536 : DEBUG / libsoup ( 2990 : 2990 ) : soup-http-input-stream.c: send_async_finished(587) > msg[0x9bc0010] error code[4]
04-02 16:35:03.536 : DEBUG / libsoup ( 2990 : 2990 ) : soup-http-input-stream.c: send_async_finished(588) > [SECURE_LOG] url [127.0.0.1:60223/index.html] GError [Cannot connect to destination (127.0.0.1)]
04-02 16:35:03.536 : DEBUG / libsoup ( 2990 : 2990 ) : soup-http-input-stream.c: soup_http_input_stream_send_finish(738) > msg[0x9bc0010] error code[4]
04-02 16:35:03.536 : DEBUG / libsoup ( 2990 : 2990 ) : soup-http-input-stream.c: soup_http_input_stream_send_finish(739) > [SECURE_LOG] url [127.0.0.1:60223/index.html] GError [Cannot connect to destination (127.0.0.1)]
04-02 16:35:03.536 : DEBUG / libsoup ( 2990 : 2990 ) : soup-request-http.c: http_input_stream_ready_cb(160) > msg[0x9bc0010] error code[4]
04-02 16:35:03.536 : DEBUG / libsoup ( 2990 : 2990 ) : soup-request-http.c: http_input_stream_ready_cb(161) > [SECURE_LOG] url [127.0.0.1:60223/index.html] GError [Cannot connect to destination (127.0.0.1)]
04-02 16:35:03.536 : DEBUG / WEBKIT ( 2990 : 2990 ) : void WebCore::sendRequestCallback(GObject*, GAsyncResult*, gpointer)(618) > [SECURE_LOG] [Network] sendRequestCallback error [Cannot connect to destination (127.0.0.1)]
04-02 16:35:03.536 : DEBUG / WEBKIT ( 2990 : 2990 ) : virtual void WebCore::SubresourceLoader::didFail(const WebCore::ResourceError&)(305) > [SECURE_LOG] [Loader] this[0x9bb0fc8], LoadError errorCode [4], url [127.0.0.1:60223/index.html]
04-02 16:35:03.536 : DEBUG / WEBKIT ( 2990 : 2990 ) : virtual void WebCore::XMLHttpRequest::didFail(const WebCore::ResourceError&)(1067) > [SECURE_LOG] [Loader] this[0x9ade1f8], url [127.0.0.1:60223/index.html], domain[Network Request Failed], errorCode[0]
04-02 16:35:03.536 : DEBUG / WEBKIT ( 2990 : 2990 ) : virtual void WebCore::XMLHttpRequest::didFail(const WebCore::ResourceError&)(1067) > [SECURE_LOG] [Loader] this[0x9ade1f8], url [127.0.0.1:60223/index.html], domain[WebKitInternal], errorCode[0]
04-02 16:35:03.536 : DEBUG / WEBKIT ( 2990 : 2990 ) : virtual void WebCore::ResourceLoader::didFail(const WebCore::ResourceError&)(379) > [SECURE_LOG] [Loader] url [127.0.0.1:60223/index.html], error domain [soup_http_error_quark], errorCode [4]
04-02 16:35:03.576 : DEBUG / RESOURCED ( 2195 : 2195 ) : proc-monitor.c: proc_dbus_active_signal_handler(107) > [proc_dbus_active_signal_handler,107] call dbus_proc_active_signal_handler

Responses

5 Replies
daniel kim

Hi,

As per below security, one application can't connect to another application via localhost. but web application&native service in hybrid application are in the same package id. so they're under same sandbox and should works. I think that there is  some limitation for this case.

   https://developer.tizen.org/node/9548?langredirect=1


http://tizen.org/privilege/internet
         If you are using the listen() and connect() functions between the local loopback interface (127.0.0.1), you cannot connect to a random application (due

         to  sandboxing) no matter how you add this privilege. However, you can connect between multiple processes of the same application binary.
 

Regards,

m kiran

Hi daniel,

Thanks for the reply. That information is worth.

We are wondering how do we give package id to hybrid application ? We see "package" info for service application in tizen-manifest.xml. But there is no tizen-manifest .xml in hybrid app. There is only config.xml and there is no package field. However there is tizen-manifest.xml in .wgt . Is that the place where we need to give the same package id ?

One more question is package name contains the app name also for ex : org.tizen.serviceapp and org.tizen.hybridapp for hybrid one. . So the question is do we need to give same package name for both the projects ?

 

Thanks for the support

-kiran

 

 

Alex Dem

Hi,
Fyi: In web apps package is pointed in config xml:
<tizen:application id="wW7RBDBXDC.hybridWebApp" package="wW7RBDBXDC" required_version="2.3"/>

After hybrid app and was built and *.wgt was created (Project (rigth click)-> Build Package) you could observe inside *.wgt both config.xml and tizen-manifest.xml.
File tizen-manifest.xml inside widget has the same package="wW7RBDBXDC" and appId looks like appid="wW7RBDBXDC.hybridefl"
see here regarding hybrid apps structure:
https://developer.tizen.org/dev-guide/2.3.0/org.tizen.gettingstarted/html/app_model/application_model_w.htm
Alexey. 

m kiran

Alex,

Thanks. Will check that 

-Kiran

AVSukhov

Hello,

If you want the applications (ui web and native service) install life cycle was the same you need that apps have the same package.