Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Talk:A simplistic HTTP Server on Windows Phone

From Wiki
Jump to: navigation, search


Tom nam - Localhost offline?

Hi Olivier,

thanks for your example. I had the problem, that my StreamSocketListener didn't response on requests on localhost, if the phone is connected to cellular AND wifi at the same time. The trick is to read the phones IP and send the request to that IP.

But still this doesn't work, if the phone is not connected to any netwok at all, because of being at a location without any cell reception.

Do you have an idea how to install a StreamSocketListener listening to http-requests from localhost even if there is no network connection to the outside?


Tom_nam (talk) 17:07, 8 October 2013 (EEST)

SB Dev -

I'm not exactlly sure what your scenario is. Are you trying to do App-to-App communication on the device doing this?

If you open a Socket using the StreamSocketListener it gets suspended as soon as you navigate away from the App. This should be true no matter what network connection you use. So when you run the server and switch to IE on the phone you should not be able to connect to the server no matter which IP address you use (Wifi address or localhost).

The StreamSocketListener in my example isn't bound to any specific IP address, so basically any request to port 80 should be received, no matter what IP address the device has.

SB Dev (talk) 17:21, 8 October 2013 (EEST)

Tom nam -

Its actually In-app-communication. I'm using the Map-Control with a custom TileSource. To use local tiles I override TileSource.GetUri and provide a uri, which is supposed to be answered by the StreamSocketListener. In the HandleRequest() I return my own tiles.

The problem is, which Ip-address to use for this Uri, if the phone has no connection to wifi or cell because then it doesn't have an ip-address.. If I use for example, HandleRequest(StreamSocket socket) is not triggered.


Tom_nam (talk) 19:17, 8 October 2013 (EEST)

SB Dev -

I see. I'm always amazed at the ideas people have to work around certain restrictions. Unfortunately I don't have an idea on how to make this work with localhost. If you iterate over all the available IP adresses on Windows Phone does not appear at all. Can the URI point to IsolatedStorage? If it can a possible way to do what you are trying to do is to write a specific file to IsolatedStorage and set the URI to that file then. I guess this is best discussed in the discussion forum instead of here in the comments as others don't regularly follow blog comments on articles by other people and someone might have an idea on how to deal with the issue.

SB Dev (talk) 19:40, 8 October 2013 (EEST)

Tom nam -

An Uri pointing to iso-storeage is ignored, this restriction is by intention from MS, many developers are complaining about this, which is also ignored my MS... I was commenting to your example, because I still didn't fully understood how this StreamSocketListener-story is working and was hoping that I missed something. Anyway, thanks again.


Tom_nam (talk) 19:50, 8 October 2013 (EEST)

Tom nam - Solved

Just a short feedback to close this issue.

with the new WP8-Update 3, which was released as a preview to developers just now, the problem is fixed. So even without any network-connection or in airplane-mode, the StreamSocketListener is now properly reacting on calls to localhost.

Thanks to Microsoft for this fix!


Tom_nam (talk) 13:54, 16 October 2013 (EEST)

SB Dev -

Thanks for the info. Great news indeed. Might be an interesting article in itself about using a custom local tile source with the Mapping control from GDR3 onwards. I'm also glad to hear that Microsoft has been busy behind the scenes on WP8.

SB Dev (talk) 14:00, 16 October 2013 (EEST)

Wrda - How to receive file?

Great article. Do you Know how can I upload file from HTML form to Windows Phone and save it to Isolated Storage?

Wrda (talk) 17:12, 28 December 2013 (EET)

SB Dev - not an easy answer

Currently the sample application does only allow requests for a certain page/file from the "server".

To do Uploads you would have to discern between GET and POST requests (rather easy - the httpMethod variable will be either GET or POST) and then you will have to read the uploaded file's data following the headers (and I can't tell you off the top of my head what format that will be in). It will no doubt be described in RFC 2616, so perhaps you can extend the sample using the information that's provided there.

SB Dev (talk) 15:49, 30 December 2013 (EET)

Tom nam - Not solved on Lumia

Another update on this issue, that calls to localhost are not responding, when there is no network-connection.

MS did a fix on GDR3-update, I posted this earlier.

But we realized now, this is only working on Samsung Ativ S. On Nokia Lumia its still not working, even with th latest wp8-update.

Tom_nam (talk) 12:02, 14 February 2014 (EET)