The-Commit-Company / frappe-react-sdk

React hooks for Frappe
https://frappe-react.vercel.app
MIT License
107 stars 36 forks source link

Issue with UseFrappeDocTypeEventListener on System IP #49

Closed HaiderAfaq closed 6 months ago

HaiderAfaq commented 9 months ago

Dear team, I am having issue in receiving events, The problem revolves around the UseFrappeDocTypeEventListener functionality. When I am working on localhost, everything operates as expected, and events are received seamlessly. However, when I attempt to access the system using my IP address (e.g., 192.168.11.111:8000), the events fail to come through. It's perplexing because all other functionalities seem to be working fine in this scenario. I checked in console, in Network tab, Socket is connected.. Please look into the matter, I will really appreciate your help

rssabbirdev commented 9 months ago

I have a similar problem with useFrappeDocTypeEventListener, when I create a new expense-item inside the Expense Record, the mutate() does not work properly, and sometimes it works but deley 5-6 seconds later. Also, I want to log something inside useFrappeDocTypeEventListener, but it does not get logged.

useFrappeDocTypeEventListener('Expense Record', (d) => { console.log('Hello I am from useFrappeDocTypeEventListener'); if (d.doctype === 'Expense Record') { mutate(); } });

HaiderAfaq commented 9 months ago

@rssabbirdev using the code as of your's useFrappeDocTypeEventListener("User", (e) => { console.log("update event:", e) updateCurrentUser() }) I get log, but only on localhost, but when I use my system IP, for running it on other system.. then I don't get any event.. that's my issue..

nikkothari22 commented 9 months ago

Hey @HaiderAfaq,

You need to check if your socket connection is being established by looking at the WebSocket Requests messages in the network tab.

I don't know your exact setup, but it could be because of your site setup or your Vite configuration. Can you share more details about your proxy configuration, whether you're running this on dev mode or on production?

HaiderAfaq commented 9 months ago

@nikkothari22 sorry for late response, my socket is connected properly.. but I don't get events on ip.. the network tab shows the same result for localhost:8000/dashboard and my ip: 192.168.11.56:8000/dashboard. but I dont recieve events on ip.. but on localhost it works flawlessly..

Screenshot from 2023-11-29 17-40-30

nikkothari22 commented 9 months ago

Where is this IP address hosted? Is it on your local machine?

HaiderAfaq commented 9 months ago

Yes sir its my local machine.. this is the same machine, where I run localhost..similarly if I run the project on server, I get the same issue..

nikkothari22 commented 9 months ago

@HaiderAfaq - do you get socket events on your Frappe desk interface when running on the IP?

HaiderAfaq commented 9 months ago

NOPE... sorry, I guess its not the issue with frappe react sdk hook.. but can you guide me what can be the issue..??? if i change any think on frappe desk... on localhost.. I don't see the changes directly on my ip: desk.. i need to refresh to get latest changes..