1
votes

Since Google App engine doesn't provide official python client API for Channel API, I followed this code https://bitbucket.org/lohre/gae_channel/src/8bd89615ac83?at=default .

Problem is I am getting "Unknown SID" error after 2-3 minutes or sometimes immediately. I also looked for the fix and found this Constant disconnects due to channels going stale for no reason .

However, proposed solution is for JavaScript Client. Can someone please look at the code and guide me how can I get rid of this error . I guess closing the connection and restart would work (as suggested), but I am not able to do it either. Any help is appreciated!! Thanks!!

1

1 Answers

0
votes

I had the same problem when I wrote a Node.js module to connect to Channel service https://github.com/gelleouet/nodejs-googleapp-channel. I copied the Java version https://github.com/gvsumasl/jacc that works properly and I found the problem. Service Channel system uses a session ID that changes while listening socket. If the new value is not well read, then this error "Unknow SID" fires each channel reconnection. There are several steps in this connection :

  1. GET /talkgadget/d : reading clientId and sessionId (see http response)

    var a = new chat.WcsDataClient("https://talkgadget.google.com/talkgadget/",
    "",
    "957778AE55824F5D", // clientId
    "Nnc1-h3uIHY", // sessionId
    "1394484158",
    "WCX",
    "AHRlWrpfZ3LMYkQU8bjBsHNPApz7SB71Sc00N5Ug"
    );        
    
  2. POST /talkgadget/dch/bind : reading SID and new sessionId (see http response)

    [[0,["c","290B58E8BA60D97F",,8] // 290B58E8BA60D97F is SID
    ]
    ,[1,["b"]
    ] // 957778AE55824F5D is new sessionId
    ,[2,["c",['957778AE55824F5D', ["ei","E4jToU4lPn0","1394484158",0,28800000,57600000,28800000] 
    ]]
    ]
    ]
    
  3. POST /talkgadget/dch/bind : nothing to do.

  4. GET /talkgadget/dch/bind : reading user message and new sessionId (all message with [xx,["c",['xxxxxx', ... contains sessionId)

    [[147,["c",['957778AE55824F5D',["cds",1395328474416]
    ]]
    ]
    

    ]

If you do not read the right SID in step 2 or the new sessionId each reading websocket, then the error 400 Unknow SID always fires.

  • First connection : request 1, 2, 3, 4. Keep request 4 alive
  • reconnect request 4 when it close
  • reconnect 1, 2, 3, 4 when error 401 (invalid token) or sometimes 400 (unknow sid)