Skip to main content

 none
Reading From Stream Error RRS feed

  • Question

  • I am trying to create and communicate over a custom Bluetooth socket but I am receiving errors when I trying to read from the input stream.  I know the other side of the connection works because I have a C# application that I can test it with.  the following code sample is my code to connect and to establish the input and output streams.  It is greatly simplified to make it easy to read here.

    echoService = new netSock.StreamSocket()
    console.log('got socket')
    echoService.connectAsync(btDevice.connectionHostName, btDevice.connectionServiceName, netSock.SocketProtectionLevel.plainSocket).done(function () {
    console.log('in socket connect')
    writer = new StorStream.DataWriter(echoService.OutputStream)
    reader = new StorStream.DataReader(echoService.InputStream)
    reader.inputStreamOptions = StorStream.InputStreamOptions.Partial

    if (reader != null) {
    console.log(reader)
      reader.loadAsync(MAX_READ).done(function (size) {
    console.log('in reader')
      })
    }
    }


    At the reader.loadAsync(MAX_READ).done line I am receiving the following error:

    0x800710dd - JavaScript runtime error: The operation
    identifier is not valid.

    From what I am reading, the 0x800710dd seems to indicate a permission error while the "Operation identifier is not valid" error seems to indicate that we are calling the function multiple times but neither one of those seem to be my problem.  I do not believe it is a permission problem because I am getting a DataReader object and the capabilities are set up the same as the C# application that works.  I do not believe I am calling the function more than once because of the console logs (not receiving multiple messages).

    I also tried the readUInt32() function from the DataReader as shown in the following code:

    var stringLength = reader.readUInt32()

    With this line I am receiving the following error:

    0x8000000b - JavaScript runtime error: The operation attempted to access data outside the valid range

    I have been using the Bluetooth Rfcomm Chat example as the basis for my code migration.  The Chat example is here:  https://code.msdn.microsoft.com/windowsapps/Bluetooth-Rfcomm-Chat-afcee559/sourcecode?fileId=86602&pathId=449509460

    Does anyone have any ideas of what may be wrong?   Any help would be appreciated.  

    EDIT 1: 

    During my experiments to try to figure out what was wrong, I decided to attempt a write to the server and I receive the same "The operation identifier is not valid" error trying to write as I do trying to read.  The error occurs in the writer.storeAsync() function.  My write code is here:

    try { console.log('writing bytes')            writer.writeBytes(bytes) console.log('store async')            writer.storeAsync().done(function (bytesWritten) {               

    console.log('written:  ' + bytesWritten)                writeCallbackSuccess('written')            })        } catch (ex) {            console.log('============Exception caught in writer=======')            console.log(ex)            sendFailedCallback('Bluetooth write errot')        }


    • Edited by Jon Hoffman123 Monday, September 12, 2016 6:30 PM Added additional information
    Friday, September 9, 2016 2:23 PM