Giter Site home page Giter Site logo

Comments (20)

grootendorste avatar grootendorste commented on July 19, 2024

Here is the precise line of code: sub = Observable.interval(timeout).subscribe(_ => ws.send(null));

Is there a reason why it's sending null?

from botframework-directlinejs.

tschnoelzer avatar tschnoelzer commented on July 19, 2024

Hi Team,

same here... just a simple test:

componentDidMount() {

   let directLine = new DirectLine({
     token: "_sdWTnasdasdasd...."
   });

   console.log("mounted");

   directLine.postActivity({
     from: { id: 'myUserId', name: 'Timo' }, // required (from.name is optional)
     type: 'message',
     text: '123'
   }).subscribe(
     id => console.log("Posted activity, assigned ID ", id),
     error => console.log("Error posting activity", error)
     );

   directLine.activity$
     .filter(activity => activity.type === 'message')
     .subscribe(
     message => console.log("received message ", message)
     );

 }

error is Unsupported data type in WebSocket.send 124:10

from botframework-directlinejs.

grootendorste avatar grootendorste commented on July 19, 2024

I'm surprised no other people are having this issue.

from botframework-directlinejs.

tschnoelzer avatar tschnoelzer commented on July 19, 2024

Perhaps its because of npm / node version ?!? I am using node 8.2.1 and npm 5.3.0 ....

from botframework-directlinejs.

grootendorste avatar grootendorste commented on July 19, 2024

I'm using v8.3.0. It also gave a problem with 6.9.1. I'm having an issue changing node versions now, I actually had to uninstall it completely because something broke. But according the comments of that Observable.interval(timeout).subscribe(_ => ws.send(null));, it's there because of some chrome issue. So I'm having this issue on iOS and Android, not in web.

from botframework-directlinejs.

billba avatar billba commented on July 19, 2024

I don't see any reason it couldn't send {} instead of null, would that fix the problem with React Native?

@dandriscoll periodically DirectLineJS sends empty messages up the WebSocket as a way of helping Chrome notice if the connection is broken so that we can reconnect. Right now we send null but are contemplating changing this to {} because React Native's WebSocket implementation doesn't allow us to send null. I assume you don't check the incoming messages on your end, but I want to be careful not to break anything.

from botframework-directlinejs.

billba avatar billba commented on July 19, 2024

Another alternative is to make this behavior optional. But I think it might be generally useful for any WebSocket implementation that, like Chrome's, is a little sleepy about noticing WebSocket disconnections.

from botframework-directlinejs.

dandriscoll avatar dandriscoll commented on July 19, 2024

Can you send an empty string? That's what the service is expecting.

from botframework-directlinejs.

billba avatar billba commented on July 19, 2024

I think so. Out of curiosity, does the service do anything with non-empty strings?

React Native people, can you try changing that null to "" and see if it works?

from botframework-directlinejs.

dandriscoll avatar dandriscoll commented on July 19, 2024

Right now nothing, but "" and null are protected from future changes in a way that other values aren't.

from botframework-directlinejs.

billba avatar billba commented on July 19, 2024

Got it. Okay, let's wait to hear from the React Native people and then I'll make the change.

from botframework-directlinejs.

billba avatar billba commented on July 19, 2024

@grootendorste @tschnoelzer we are waiting for your feedback on his one.

from botframework-directlinejs.

grootendorste avatar grootendorste commented on July 19, 2024

Hi I'll try tonight, sorry I wasn't at my laptop for a while.

from botframework-directlinejs.

billba avatar billba commented on July 19, 2024

@grootendorste @tschnoelzer any news for us, React Native folks?

from botframework-directlinejs.

grootendorste avatar grootendorste commented on July 19, 2024

Hi all, sorry I've been on my other github account. A while ago I forked the repo and removed the .send(null) part and since then I haven't had any issues on any browser (on React) or any device (on React-Native). I apologize, I have not sent in an empty string (.send('')) yet to see if it works. But up until now removing the send completely has worked for me. I realize it's a cheap fix, but at the time I was in a rush.

from botframework-directlinejs.

billba avatar billba commented on July 19, 2024

@grootendorste Thank you for the response. Unfortunately this doesn't help us evaluate the solution on the table.

from botframework-directlinejs.

grootendorste avatar grootendorste commented on July 19, 2024

@billba Sending {} instead of null also does fix the solution. I'm not a fan of quick fixes that I can't really motivate, can anyone explain why this is a good idea?

from botframework-directlinejs.

billba avatar billba commented on July 19, 2024

@grootendorste we're looking to see if send("") fixes the solution.

This is not a quick fix.

We periodically ping the server to see if the connection is still good. We can't send just any message, but
our server specifically ignores null and "" as messages, so those are safe as pings. We had been sending null, which works in the browser, but breaks React Native. So since none of us here use React Native, we are trying to find out if send("") works on React Native.

from botframework-directlinejs.

colewinans avatar colewinans commented on July 19, 2024

@billba send("") does indeed work. Confirming on React Native 0.50.

from botframework-directlinejs.

billba avatar billba commented on July 19, 2024

Hooray, thank you @colewinans!

from botframework-directlinejs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.