Answered by:
Using StreamWebSocket in c++ windows Store app

Question
-
I am trying to read data from a web page using StreamWebSocket class. But I am getting unhandled exception as below:
"Unhandled exception at 0x60FA8AE3 (msvcr110d.dll) in Task.exe: An invalid parameter was passed to a function that considers invalid parameters fatal.( it appears in file invarg.c )"
Here is the code I am trying:
What could be wring with this? My intention is to read the contents of the web page.// s is class member of type StreamWebSocket. s = ref new StreamWebSocket(); Uri^ u = ref new Uri( "wss://http://msdn.microsoft.com/en-us/library/hh438388(v=vs.85).aspx" ); task<void>(s->ConnectAsync( u )).then([this]( task<void> p) { try { OutputDebugString( L"complete" );
// get the input stream and read data } catch( ...) { } });
Thursday, September 27, 2012 8:27 PM
Answers
-
I apologize, I meant the opposite. wss:// if for a secure socket. ws:// would be an unsecure socket.
Also search the samples and understand how they work as that will help you understand the proper usage of WebSockets:
-Jeff
Jeff Sanders (MSFT)
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Monday, October 1, 2012 5:46 PM
- Marked as answer by Jesse Jiang Monday, October 8, 2012 6:09 AM
Monday, October 1, 2012 5:46 PMModerator
All replies
-
drop the wss:// and only use https:// Also consider only using IXMLHttpRequest instead
Jeff Sanders (MSFT)
- Edited by Jeff SandersMicrosoft employee, Moderator Monday, October 1, 2012 11:51 AM
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Monday, October 1, 2012 11:51 AM
Monday, October 1, 2012 11:51 AMModerator -
I tried using https://
= ref new StreamWebSocket(); Uri^ u = ref new Uri( "https://http://msdn.microsoft.com/en-us/library/hh438388(v=vs.85).aspx" ); task<void>(s->ConnectAsync( u )).then([this]( task<void> p) { try { OutputDebugString( L"complete" ); } catch( ...) { } });
but it gave the following error:
WinRT information: 'uri': WebSocket URIs require a 'ws://' or 'wss://' scheme.
- Edited by its_me_here Monday, October 1, 2012 5:22 PM
Monday, October 1, 2012 5:21 PM -
I apologize, I meant the opposite. wss:// if for a secure socket. ws:// would be an unsecure socket.
Also search the samples and understand how they work as that will help you understand the proper usage of WebSockets:
-Jeff
Jeff Sanders (MSFT)
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Monday, October 1, 2012 5:46 PM
- Marked as answer by Jesse Jiang Monday, October 8, 2012 6:09 AM
Monday, October 1, 2012 5:46 PMModerator