informed
Posts: 128
Joined: Mon Oct 26, 2015 6:24 pm

WebSockets in Windows 10

Wed Dec 30, 2015 6:54 pm

Hi,

I am using the Raspberry Pi2 with Windows 10 shell installed.

I would like to serve basic web pages using HTML + Javascript . I am sure I can work this out for myself. But before I start is it possible to serve a web-socket? If so is there an example code?

I am using c#.

Merry xmas and New Year all.

Thanks

ricl
Posts: 657
Joined: Wed Aug 26, 2015 11:55 am

Re: WebSockets in Windows 10

Wed Dec 30, 2015 8:49 pm

Do you want sockets themselves or will an HTTPClient work for what you plan? EDIT: I see you said serve not read, HTTPClient is not suitable for that.

Both are supported, in different classes which work in all the UWP languages, C#, JavaScript, etc..

https://github.com/Microsoft/Windows-un ... reamSocket
ricl : F/gamma = ma : Law ii(a) : https://climatedatablog.wordpress.com/2016/01/02/an-energy-challenge-2016/ #AnEnergyChallenge2016

informed
Posts: 128
Joined: Mon Oct 26, 2015 6:24 pm

Re: WebSockets in Windows 10

Wed Dec 30, 2015 9:02 pm

Hi I need to send data to my web browser clients. So, my user will go to a browser type in the IP address of my device. I have an http listener which will serve html pages. I would then want to open a socket between client and server to render images without the browser being refreshed. Currently I have this set up from my web server hosted with fast hosts. I am now looking to see if I can port this over to the raspberry pi acting as my server to my local clients on same network. I also currently use web sockets to tunnel direct to my browser clients. Thanks for the link . I will be able to see if it is what I want when in front of PC as on mobile phone at mo

ricl
Posts: 657
Joined: Wed Aug 26, 2015 11:55 am

Re: WebSockets in Windows 10

Wed Dec 30, 2015 11:18 pm

Make sure you enable the Pi firewall to allow you network traffic through. Most of what you need is probably in the FAQ. If it is not there I'll try and extend it to included any answers you need.

Have a good New Year
ricl : F/gamma = ma : Law ii(a) : https://climatedatablog.wordpress.com/2016/01/02/an-energy-challenge-2016/ #AnEnergyChallenge2016

informed
Posts: 128
Joined: Mon Oct 26, 2015 6:24 pm

Re: WebSockets in Windows 10

Thu Dec 31, 2015 11:26 am

thanks for all of this and your time.

i shall now spend some time reviewing the link and FAQs.

Happy new year to you too.

Cheers!

wesch
Posts: 4
Joined: Mon Jan 04, 2016 3:28 pm

Re: WebSockets in Windows 10

Mon Jan 04, 2016 3:41 pm

I've started to write a more sophisticated web server than all the samples I've found. I adopt it from a solution I have for the .NetMF. It supports currently sending html content either generated by code or read from SD card. Later on I will implement multiplart parser for ability to also upload files. on .NetMF this already works, so I do not see any serious problems.

Last weeks (between christmas and new year) I started to implement web sockets. Handshaking and switching protocol already works and I did send also some data. Pinging is not yet implemented.

The most problems I have are asynchronous functions in windows 10. The server runs in a backround task and does not realy need async functionality. But for some methods in W10 only exist async methods. And mixing them results in serious problems.

If someone is willing to support me, contact me and I can provide with the sources.

informed
Posts: 128
Joined: Mon Oct 26, 2015 6:24 pm

Re: WebSockets in Windows 10

Mon Jan 04, 2016 5:07 pm

hi,

thanks for your post.

I am happy to work with you in my spare time.

Please send me what you got and I will do my best to assist.

Thanks

ricl
Posts: 657
Joined: Wed Aug 26, 2015 11:55 am

Re: WebSockets in Windows 10

Mon Jan 04, 2016 5:26 pm

" But for some methods in W10 only exist async methods. And mixing them results in serious problems."

This is Windows 10. async is designed to stop the programmer from locking up the UI. If it worked in Windows 8 or above it will now. Code from before that needs to change. Asking for all the old sync stuff isn't going to work unless you want to do Win32.
ricl : F/gamma = ma : Law ii(a) : https://climatedatablog.wordpress.com/2016/01/02/an-energy-challenge-2016/ #AnEnergyChallenge2016

informed
Posts: 128
Joined: Mon Oct 26, 2015 6:24 pm

Re: WebSockets in Windows 10

Wed Jan 06, 2016 1:44 pm

@ricl

Believe it or not I have now got the time to look at that link you kindly posted to me.

From the narrative it implied that i cannot serve web sockets on Raspberry Pi 2? This is not a surprise to me but i wanted to clarify this?

thanks

ricl
Posts: 657
Joined: Wed Aug 26, 2015 11:55 am

Re: WebSockets in Windows 10

Wed Jan 06, 2016 4:20 pm

Well the essence is in

using Windows.Networking;
using Windows.Networking.Connectivity;
using Windows.Networking.Sockets;
using Windows.Storage.Streams;
ricl : F/gamma = ma : Law ii(a) : https://climatedatablog.wordpress.com/2016/01/02/an-energy-challenge-2016/ #AnEnergyChallenge2016

informed
Posts: 128
Joined: Mon Oct 26, 2015 6:24 pm

Re: WebSockets in Windows 10

Wed Jan 06, 2016 4:27 pm

@ricl Hi, thanks for posting again and sorry for being so dumb but I still do not understand :(. For the web socket to work and send data to my HTML pages without postback i need to support the ws protocol.

On that link you kindly sent me it says at the end that web sockets (server-side) are not supported on ARM devices and that i would have to use a proxy server instead.

Or am I missing something?

Thanks so much for your time. it is appreciated...

ricl
Posts: 657
Joined: Wed Aug 26, 2015 11:55 am

Re: WebSockets in Windows 10

Wed Jan 06, 2016 5:22 pm

Ah I think I see the confusion. True there are no web sockets as a server. There are sockets which you can use to make one though. You just don't have access to the higher libraries that is all because those are in the Desktop sku.
ricl : F/gamma = ma : Law ii(a) : https://climatedatablog.wordpress.com/2016/01/02/an-energy-challenge-2016/ #AnEnergyChallenge2016

informed
Posts: 128
Joined: Mon Oct 26, 2015 6:24 pm

Re: WebSockets in Windows 10

Wed Jan 06, 2016 5:29 pm

Hi,

i am definitely intrigued with this statement:

There are sockets which you can use to make one though.

as this is what I am after and I have been looking for sometime.

Do you have an example/link I can look at?

thanks

ricl
Posts: 657
Joined: Wed Aug 26, 2015 11:55 am

Re: WebSockets in Windows 10

Wed Jan 06, 2016 7:45 pm

To do what? Run a web server? Try the blinky web server example. Run some other protocol. Use one of the socket classes available.

IN all UWP languages.

Just the multi thread web server classes are not there AFIK
ricl : F/gamma = ma : Law ii(a) : https://climatedatablog.wordpress.com/2016/01/02/an-energy-challenge-2016/ #AnEnergyChallenge2016

informed
Posts: 128
Joined: Mon Oct 26, 2015 6:24 pm

Re: WebSockets in Windows 10

Wed Jan 06, 2016 7:51 pm

hi,

you are just not getting it are you..

but thanks for your time

informed
Posts: 128
Joined: Mon Oct 26, 2015 6:24 pm

Re: WebSockets in Windows 10

Wed Jan 06, 2016 7:51 pm

webSockets

*sending binary data*

*not http server*

ricl
Posts: 657
Joined: Wed Aug 26, 2015 11:55 am

Re: WebSockets in Windows 10

Thu Jan 07, 2016 12:31 am

REST servers in UWP or Win32 are http underneath and carry streams of any arbitrary protocol as their body
Which language you use is dependent on skills and requirements
ricl : F/gamma = ma : Law ii(a) : https://climatedatablog.wordpress.com/2016/01/02/an-energy-challenge-2016/ #AnEnergyChallenge2016

informed
Posts: 128
Joined: Mon Oct 26, 2015 6:24 pm

Re: WebSockets in Windows 10

Thu Jan 07, 2016 7:11 am

Hi am not talking about rest api.
When you serve a html 5 page, in the JavaScript you can open up a web socket to a server. This can then act as a duplex comms. From there I can send binary data from the server to that JavaScript client. In that JavaScript I can then that binary array and convert to an array buffer to load an image to the canvas control.
The best a rest api could give me is long polling which is not what I want.

informed
Posts: 128
Joined: Mon Oct 26, 2015 6:24 pm

Re: WebSockets in Windows 10

Thu Jan 07, 2016 7:11 am

But I appreciate you comments

informed
Posts: 128
Joined: Mon Oct 26, 2015 6:24 pm

Re: WebSockets in Windows 10

Thu Jan 14, 2016 12:34 pm

just in case you are interested there is this:

https://github.com/sensaura-public/iotweb

ricl
Posts: 657
Joined: Wed Aug 26, 2015 11:55 am

Re: WebSockets in Windows 10

Thu Jan 14, 2016 8:33 pm

Thanks for the ref
ricl : F/gamma = ma : Law ii(a) : https://climatedatablog.wordpress.com/2016/01/02/an-energy-challenge-2016/ #AnEnergyChallenge2016

informed
Posts: 128
Joined: Mon Oct 26, 2015 6:24 pm

Re: WebSockets in Windows 10

Thu Jan 14, 2016 9:31 pm

You are welcome :)

informed
Posts: 128
Joined: Mon Oct 26, 2015 6:24 pm

Re: WebSockets in Windows 10

Fri Jan 15, 2016 5:52 pm

hi,

this statement:

Make sure you enable the Pi firewall to allow you network traffic through

Where can i find these settings?

thanks

ricl
Posts: 657
Joined: Wed Aug 26, 2015 11:55 am

Re: WebSockets in Windows 10

Sat Jan 16, 2016 4:17 am

In the FAQ.
ricl : F/gamma = ma : Law ii(a) : https://climatedatablog.wordpress.com/2016/01/02/an-energy-challenge-2016/ #AnEnergyChallenge2016

informed
Posts: 128
Joined: Mon Oct 26, 2015 6:24 pm

Re: WebSockets in Windows 10

Sat Jan 16, 2016 9:08 am

thanks. I keep forgetting about that FAQ. It has some good stuff in it. Tell me, would you know how to disable the Windows Update on this device? It seems to be a new feature since the upgrade.

Return to “Windows 10 for IoT”