Iot Hub sevice streaming (preview) = websocket aborts and crashes #986
Labels
bug
Something isn't working.
device-streaming
Issues related to Device Streaming feature (currently in preview).
investigation-required
Requires further investigation to root cause this.
IoTSDK
Tracks all IoT SDK issues across the board
Description of the issue:
The connection is initiated through a device connection to the iot hub which allows me to get the device ID, then, using code modified from the samples provided on Github, I try send data with iot hub device streaming which crashed on the server side (Azure service fabric) and app (UWP)
System.Net.WebSockets.WebSocketException (0x80004005): Unable to connect to the remote server ---> System.ArgumentException: The base stream is not writeable.
Parameter name: stream
at System.Net.WebSockets.WebSocket.CreateFromStream(Stream stream, Boolean isServer, String subProtocol, TimeSpan keepAliveInterval)
at System.Net.WebSockets.WebSocketHandle.ConnectAsyncCore(Uri uri, CancellationToken cancellationToken, ClientWebSocketOptions options)
at System.Net.WebSockets.WebSocketHandle.ConnectAsyncCore(Uri uri, CancellationToken cancellationToken, ClientWebSocketOptions options)
at System.Net.WebSockets.ClientWebSocket.ConnectAsyncCore(Uri uri, CancellationToken cancellationToken)
at V2Vehicle.Helpers.DeviceStreamingCommon.GetStreamingClientAsync(Uri url, String authorizationToken, CancellationToken cancellationToken) in C:\Users\Mathi\source\repos\AIRPROX backend (fabric)\V2Vehicle\Helpers\DeviceStreamingCommon.cs:line 24
at V2Vehicle.V2Vehicle.<>c__DisplayClass7_0.<b__0>d.MoveNext() in C:\Users\Mathi\source\repos\AIRPROX backend (fabric)\V2Vehicle\V2Vehicle.cs:line 188
On the app side, the thing crashed saying that the websocket is in aborted state.
Please help !
Code sample exhibiting the issue:
Server code:
`
public async Task HandleStreamsRegistrationDataAsync(ActorStreamsRegistration data)
{
// Save data to statemanger to help recover in case of crash/restart...
// TODO : And populate variables (quicker)
VehicleSerialNumber = data.VehicleSerialNumber;
VehicleUniqueId = data.VehicleUniqueId;
VehicleGeneration = (SystemVersionConstants)data.VehicleGeneration;
VehicleDescription = data.VehicleDescription;
VehicleDeviceType = (AirproxObjectTypes)data.VehicleDeviceType;
vehicleUserGroup = data.VehicleUserGroup;
vehiclePrivateMode = data.VehiclePrivateMode;
AdditionalData = data.AdditionalData;
vehicleDeadManSignlInterval_ms = data.VehicleDeadManSignlInterval_ms;
VehicleMovementThreshold_m = data.VehicleMovementThreshold_m;
VehicleTimeMovementThreshold_ms = data.VehicleTimeMovementThreshold_ms;
`
Client code:
` protected override async void StartMessageEmitterTask()
{
streamTokenSource = new CancellationTokenSource();
Debug.WriteLine("Starting emitter task");
await Task.Run(async () =>
{
while (true)
{
var streamRequest = await deviceClient.WaitForDeviceStreamRequestAsync(streamTokenSource.Token).ConfigureAwait(false);
The text was updated successfully, but these errors were encountered: