Support Topics Documentation Slack YouTube Blog

Backendless Realtime updates not working


(Steven Salmon) #1

In my project realtime updates were working fine about a week ago. Gone back to the project today and they are no longer working. I created a gitrepo to demonstrate a similar technique to what was provided in the backendless angular blog post. I can see no reason to why these updates are not working? I continually get http requests made to https:// ** rt/lookup addresses which appear to be a fallback of some kind!

https://github.com/thedigitalpro/backendless-realtime-test

Appreciate any pointers.

Many thanks

Steven


(Vladimir Upirov) #2

Hi Steven
Looks like the problem is also with Angular build system,
the builder can not resolve “global” object when building a bundle for browsers that’s the reason why your app doesn’t work.

so, I found out two workarounds how to fix that:

the first, is to specify path to socket.io build for browser in tsconfig.json,

 "socket.io-client": [
     "./node_modules/socket.io-client/dist/socket.io"
 ]

just like you did it here: Backendless SDK + Angular results in compile error!

and the other one is to add a polyfill for “global” to polyfills.ts

(window as any).global = window;

like here: https://stackoverflow.com/a/50488337/7026583

I assume the last one is more better way


(Steven Salmon) #3

@vladimir-upirov this is extremely helpful and has solved the problem thank you. What puzzles me is that your example on your repo https://github.com/Valodya/backendless-angular works perfectly fine without any changes you have mentioned. Any ideas on this one?

Thank you once again for your help.


(Vladimir Upirov) #4

I guess it’s because I didn’t use “–prod” flag for building


(Steven Salmon) #5

Its odd because both projects were running locally without the --prod. Your project worked without change, other than the app id etc. It’s a mystery.


(Vladimir Upirov) #6

yeah, but you added the next definitions for getting “ng build --prod” working, don’t you?

"paths": {
  "backendless": [
    "./node_modules/backendless/lib/index.js"
  ],
  "backendless-rt-client": [
    "./node_modules/backendless-rt-client/lib/index.js"
  ],
  "backendless-request": [
    "./node_modules/backendless-request/dist/backendless-request.js"
  ]
}

(Steven Salmon) #7

Yes correct I just did this as a matter of course. This issue was being experienced without doing a prod build. I just simply run ng serve and experienced the problem locally.


(Vladimir Upirov) #8

yes, since you have re-defined paths to Backendless modules ng serve won’t work as before, because without that Angular gets an assembled Backendless JS-SDK for browser (from node_modules/backendless/dist/backendless.js) and it works, but it doesn’t when you run ng build --prod =)