In this post I will lead you through the process of installing the WebSockets prototype on your machine. By the end of this tutorial you should have a working chat web application sample.
First you need to download and run the WebSockets prototype installer.
This package installs the binaries and samples in the %ProgramFiles%\Microsoft SDKs\WCF WebSockets\10.12.16 folder.
Make sure IIS is enabled on your machine. You can verify this by using the Windows feature configuration tool.
Configure the Windows Firewall
You need to allow incoming TCP traffic on port 4502 in the Windows Firewall.
Open the Windows Firewall and add a new inbound rule.
To add a new inbound rule you need to follow the five steps of the wizard.
First you need to define the type of rule you want to create: Port.
The protocol you need to use is TCP and the specific port you want to open is 4502.
When connections are attempted through the port we specified, they should be allowed.
This rule should always be applied (for me).
Finalize the wizard by specifying a name for the rule.
Deploy the client access policy
Copy the %ProgramFiles%\Microsoft SDKs\WCF WebSockets\10.12.16\bin\clientaccesspolicy.xml file to the %SystemDrive%\inetpub\wwwroot folder.
Make sure the file is accessible by navigating to http://localhost/clientaccesspolicy.xml.
Start the ChatService
Start %ProgramFiles%\Microsoft SDKs\WCF WebSockets\10.12.16\bin\ChatService.exe.
Because the ChatService assembly is delay signed, and not fully signed, it will throw an unhandled System.Security.SecurityException: Strong name validation failed.
To turn off strong name signing for this assembly you can use sn.exe. Execute the following command:
sn -Vr "%ProgramFiles%\Microsoft SDKs\WCF WebSockets\10.12.16\bin\ChatService.exe"
- The command arguments are case sensitive. It's -Vr.
- If you are running a 64 bit OS you have to use the 64 bit version of the tool. I used the Visual Studio x64 Win64 Command Prompt (2010).
- If you are using the Visual Studio Command Prompt you need to run it as an administrator.
Once these problems are fixed, you can finally start the ChatService.
Deploy the Chat web application
Create a chat virtual directory in IIS mapped to the %ProgramFiles%\Microsoft SDKs\WCF WebSockets\10.12.16\web\chat directory.
Test the web application
If you followed all these steps, you should be able to navigate to http://localhost/chat/wsdemo.html and see the results of your efforts. Victory!
If you are still facing some problems, feel free to let me know in the comments.