3 Replies Latest reply on Mar 2, 2018 6:44 PM by ray

    Error when creating web socket


      I'm trying to use the 'Channel' feature to setup a websocket.  I have PI Web API 2017 R2 SP1 installed. I'm only getting the following error reported:


      "The protocol of the request is not supported." no matter what I try. 


      I'm using the following URL to try to create the channel:



      I'm seeing the following message in the Event Viewer 'debug' log for the PI Web Server:

      [Controllers] {490fb31c-67ac-4bf2-996c-a7cb53e44047}: OSIsoft.REST.PIWebException: The protocol of the request is not supported.

         at OSIsoft.REST.Core.Controllers.ChannelController.ValidateChannelRequest()

         at OSIsoft.REST.Core.Controllers.ChannelController.StreamGetChannel(String webId, Boolean includeInitialValues, Int32 heartbeatRate, String webIdType)

         at lambda_method(Closure , Object , Object[] )

         at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClassc.<GetExecutor>b__6(Object instance, Object[] methodParameters)

         at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)

      --- End of stack trace from previous location where exception was thrown ---

         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

         at System.Web.Http.Controllers.ApiControlle


      Am I missing something silly?  Some configuration option?



        • Re: Error when creating web socket

          His David,


          The channel protocol is wss not https. Hope it was that silly!



          1 of 1 people found this helpful
          • Re: Error when creating web socket

            Hi David.


            The Request Rejected feature of the PI Web API uses a different protocol than HTTP, it uses the WebSockets protocol. As such, your URI should be in the form of wss://myserver/piwebapi/streams/{webId}/channel. Note that instead of https leading my URI I have instread wss.


            To test this feature out, you'll have to do a little bit of programming. The documentation for the Channels feature includes two small samples that you can test Channels out with. I like using the JavaScript example as you can copy and paste the example code into the Console tab of the Developer Tools windows in Chrome. Once you copy and paste the code into the Console, make sure to update the "myserver" and "{webid}" portion of the URI to point your PI Web API server and the WebId that you are interested in. Then hit enter to execute the code.


            Let me know if you have any questions for me.



            3 of 3 people found this helpful