RocketChat / Rocket.Chat.js.SDK

Utility for apps and bots to interact with Rocket.Chat via DDP and/or API
MIT License
136 stars 94 forks source link

driver.connect() not working #136

Open officialabdulrehman opened 3 years ago

officialabdulrehman commented 3 years ago

Hi there! I hope you are having a nice day.

I have been trying to use @rocket.chat/sdk in my React app.

SERVER DETAILS

Deployment Version 3.15.0 Deployment ID RFJ4fpYQA2vC2cNLA Apps Engine Version 1.26.0 Node Version v12.22.1 Database Migration 225 (June 11, 2021 9:25 AM) MongoDB 4.0.24 / mmapv1 (oplog Enabled) Commit Details HEAD: (55457025d) Branch: HEAD PID 23

I have been able to interact with the REST-api with { api } but the driver { driver } doesn't work. How can I use realtime features with this sdk

`import { driver, api } from '@rocket.chat/sdk';

api.login({username: USER, password: PASS}).then(info => { api.get('subscriptions.get') }) // THIS WORKS

driver.connect() // THIS DOESN'T WORK `

ERROR

Uncaught (in promise) TypeError: net.connect is not a function at new Client (client.js:43) at DDP.connect (ddp.js:61) at new DDP (ddp.js:54) at Asteroid.push../node_modules/asteroid/dist/asteroid.node.js.Asteroid._init (asteroid.node.js:366) at new Asteroid (asteroid.node.js:26) at driver.ts:107 at new Promise () at Object.connect (driver.ts:103) at App (App.js:21) at renderWithHooks (react-dom.development.js:14985) at mountIndeterminateComponent (react-dom.development.js:17811) at beginWork (react-dom.development.js:19049) at beginWork$1 (react-dom.development.js:23940) at performUnitOfWork (react-dom.development.js:22776) at workLoopSync (react-dom.development.js:22707) at renderRootSync (react-dom.development.js:22670) at performSyncWorkOnRoot (react-dom.development.js:22293) at scheduleUpdateOnFiber (react-dom.development.js:21881) at updateContainer (react-dom.development.js:25482) at react-dom.development.js:26021 at unbatchedUpdates (react-dom.development.js:22431) at legacyRenderSubtreeIntoContainer (react-dom.development.js:26020) at Object.render (react-dom.development.js:26103) at Module. (index.js:7) at Module../src/index.js (index.js:18) at webpack_require (bootstrap:856) at fn (bootstrap:150) at Object.1 (reportWebVitals.js:14) at webpack_require (bootstrap:856) at checkDeferredModules (bootstrap:45) at Array.webpackJsonpCallback [as push] (bootstrap:32)

HarrisDePerceptron commented 3 years ago

@officialabdulrehman can you mention the server version and the sdk version that you are using. this seems to be a problem while using it in React.