Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9131629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:10:18+00:00 2026-06-17T08:10:18+00:00

I want to use the channel api to push updates to open pages, What

  • 0

I want to use the channel api to push updates to open pages, What I have done so far is to store the page client ids in ndb – I have included a code summary

My question is:
How do I manage closed pages and expired tokens?

and is this the best way to push updates to many open pages?

open page code:

import webapp2
import uuid
from google.appengine.api import channel
from google.appengine.ext import ndb

class Frame(ndb.Model):
  clientID = ndb.StringProperty()
  date = ndb.DateTimeProperty(auto_now_add=True)

class MainHandler(BaseHandler):
    def get(self):
        client_id = str(uuid.uuid4())
        channel_token = channel.create_channel(client_id)
        frame = Frame(clientID = client_id)
        frame.put()

        self.render_response('home.html',** "token":channel_token,"client_id":client_id)

send message code:

from google.appengine.api import channel
from google.appengine.ext import ndb

class Frame(ndb.Model):
  clientID = ndb.StringProperty()
  date = ndb.DateTimeProperty(auto_now_add=True)

frames = Frame.query().fetch(10)

for i in frames:
   channel.send_message(i.clientID, "some message to update")
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:10:19+00:00Added an answer on June 17, 2026 at 8:10 am

    When you enable channel_presence, your application receives POSTs to the following URL paths:

    POSTs to /_ah/channel/connected/ 
    POSTs to /_ah/channel/disconnected/ 
    

    These signal that the client has connected to the channel and can receive messages or has dicsonnected.

    Tracking_Client_Connections_and_Disconnections

    Dealing with expired tokens:

    By default, tokens expire in two hours, unless you explicitly set an expiration time by providing the duration_minutes argument to the create_channel() function when generating the token. If a client remains connected to a channel for longer than the token duration, the socket’s onerror() and onclose() callbacks are called. At this point, the client can make an XHR request to the application to request a new token and open a new channel.

    So on your onerror function you basically do it all over again just like the original connection.

    Tokens and security

    To send updates to many open pages simply iterate round your list of connected users and send them the message individually. There is no “transmit to all” functionality.

    You may also want to build in a “heartbeat” that sends messages to supposedly connected clients and remove them if no reply. This is because sometimes (apparently) the disconnected messages are not sent (power failure, whatever) when the browser window is closed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know if we can use Youtube V3 API to retrieve channel
i want use some data from a website with web service. i have a
We have a powerbuilder application and we want use a scanner through this application
I want to use Originate API of Asterisk to place an outbound call on
I have some Ruby web apps that use OpenID for authentication and store the
I use VS 2010 in Win7. I want use IRC programatically, using IRC client
I have a video that I want to use on an app that has
I'm using primefaces 3.1, and I want to use the PrimeFaces Push. I want
I want to use the facebook like button for a facebook fan page, but
We have REST API with a collection of channels. When requesting a channel, should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.