comet.c cannot work with more than one page opened in browser - browser

It works well when comet.c is opened in different browser simultaneously, one page per browser.
When I opened two pages of comet.c in a browser, no matter firefox or chrome, only the first page received and displayed data.
The second page were hanged until the first page was closed.
In the user's point of view, it is abnormal.
Who can tell what's wrong, browser or push_list_add() or the comet.js?
All pages requested freq. of one update per second.

It works well when comet.c is opened in different browser simultaneously, one page per browser... but with several pages in a single browser only the first page works.
It looks like a client issue: if that was the server then comet.c would not work with different client programs used simultaneously.

[solved]
In client side, add a timestamp at the end of the url in the form action.
var url = "/?comet.c&feed=livestock&delay="+escape(delay)+"&"+(new Date().getTime());
Done.

Related

How does Blazor hijack the Browser-Back button?

Blazor-Server apps use the SignalR circuit.
I can somewhat understand how there is JS that change events happening from the DOM, so instead of sending a new HTTP GET request the framework manipulates the DOM and displays the new blazor page.
But how is it even possible that the circuit is still active and working on page back button? This is a BROWSER FEATURE, not some html element, which can be changed, right? Would it not be a security issue if the browser back button behavior can be manipulated in different ways?
Not firing a new HTTP GET request on page back seems pretty hacky. Wouldn't that allow for malicious websites to do the same? Can websites access the last page visited with that??
How does the browser "know" that the last page should also use the same websocket circuit?
Is it then possible to tell the browser that it should establish a websocket on a past page, that didn't even have any before (would seem like a security risk)?
How does the back button differ from hitting "enter" in the address bar (which will always cut and establish a new circuit)?
Is the back button exactly the same as calling JS history.back() ?

Started fullstackopen for the first time and getting a "favicon.ico" request in the network tab

So I basically started this web dev course by fullstackopen and in one of the steps it says that once you open the Developer Console, and refresh the tab, 2 requests shall appear (one HTTP GET request and the another for an image to be retrieved from the server, but whenever I refresh I get this unknown request called "favicon.ico" every time. For the next steps also the same is happening. While the courses explains all the other requests made, it does not even talk about this one because this does not appear in their examples. So I just wanted to know why I am getting this random request. first one is what the network tab should have displayed
second image shows what I get when I follow the instructions of the course
As Akki mentioned, this is the icon you would see on a tab in the browser. Like the StackOverflow icon for this page.
You are getting a status 200 response, so it does find it in your root
Modern browsers will show an icon to the left of the URL. This known as the favicon.ico and is typically fetched from website.com/favicon.ico. Your browser will automatically request it when browsing to different sites. If your browser receives a valid favicon.ico file, it will display this icon. If it fails, it will not display a special icon.
In either circumstances, browsing is not affected.
It would seem that you don't have a favicon in your root directory of the project thus the unknown request

Checking other users are viewing this page in Node Express

I have a NodeJs Express app and when a particular user goes to a page/route would like to identify and display if another user is currently viewing the page as well. So for example it would say "Jerry currently viewing this page" and someone else goes there.
Is there any easy/lightweight way to do this?
First off, with a regular web page, the server only knows who and when a page was requested. It doesn't, all by itself, know whether that user is still viewing that page or not. The user could have closed the browser, typed something else in the URL bar, the computer could have gone to sleep, etc...
Second off, even if the page is still being displayed in the browser, you can't know if someone is actually there at the computer or not. The best you could do is to try to keep track of activity in that web page (last mouse click, recent mouse movements over the web page, etc...).
Then, to even have any idea of the web page is even still open in the browser, you need some way of tracking that notion. There are two possibilities I can think of.
You can have some Javascript in the web page that regularly (say once every few minutes) sends a small little ajax call to your server that basically just says "I'm still here". This wouldn't know immediately when they left the page, but if the server finds that the usual every few minutes ajax call didn't come, then the server can change the status of that user on that page to not there any more.
If that web page makes a webSocket or socket.io connection to the server and keeps that connection alive, then whenever the browser closes or the user closed that tab or navigates to another page, that webSocket or socket.io connection will get automatically closed and the server will be notified that the socket got closed. Using this technique, the server can know pretty much right away when the user leaves the page.

How browser displays a static website contents without any confusion, when two requests are fired from a browser in different tabs

I'm a web developer, I just want to know how things work behind the scenes when a request is fired.
Suppose let's assume I've a static website, I requested about us page in one tab, contact us in other tab, both the requests are fired at the same time..
when the requests are fired at the same time, How browser displays the content in respective tabs correctly ?
Thanks in advance..
I think you are looking for process id,
In browser each tab have different process id ( you can see that is task manager )
This seperates the send and receiving of the data in each tab...

browser related question

I get different behavior between IE and Mozilla.
Say for ex I have 2 buttons on my webpage. Button-1 and Button-2
In mozilla browser, when I click Button-1 then it process the click request of Button-1, while it is processing the request, immediately if I Click on button-2, browser will not proceed request for Button-2.
In IE browser, after clicking Button-1 If I immediately click Button-2 then it will first process request of Button-1 and then it will process request for Button-2.
Why there is different behavior for both browser for same web page?
PS. IE 8 and Mozilla 3
Thats's life
Browser differences are one of the biggest hurdles in modern web development. You're best bet is to paste the code to let users take a look.

Resources