keep alive tråd

Added by John about 4 years ago


Jag kör mot testmiljön. Jag blir märkligt nog konsekvent nedkopplad efter ca 1 sekund.

Jag kör nu en keepalive tråd där jag gör Touch Session varje sekund. Det håller igång anslutningen och löser mitt problem. Men så fort jag ökar intervallet mellan mina Touch Session till 2 sekunder eller mer så hinner jag bli nedkopplad.

Intreeserad att veta vad detta beror på då jag hade förväntat mig att bli nedkopplad först efter 300 sekunder.


Replies (10)

RE: keep alive tråd - Added by Lars about 4 years ago

Vad menar du med "nedkopplad"? Touch Session håller din inloggning (session_key) vid liv men inte nödvändigtvis din "socket". Hur kopplar du upp?

RE: keep alive tråd - Added by John about 4 years ago

Jag använder python. Loggar in enligt nedan och gör sedan ett testanrop vilket fungerar. Väntar jag med mer än 2 sekunder failar dock anropet
Jag har alltså endast problem med REST API. public och private feed fungerar och ger heartbeats var 5:e sekund

from Crypto.Cipher import PKCS1_v1_5
from Crypto.PublicKey import RSA
import httplib
import urllib
import base64
import time
import json
import socket, ssl
import datetime

username = 'xxx'
password = 'xxx'
service = 'NEXTAPI'
URL = ''
connection = httplib.HTTPSConnection(URL)

timestamp = int(round(time.time() * 1000))
timestamp = str(timestamp)
b64_username = base64.b64encode(username.encode('utf-8')).decode("utf-8")
b64_password = base64.b64encode(password.encode('utf-8')).decode("utf-8")
b64_timestamp = base64.b64encode(timestamp.encode('utf-8')).decode("utf-8")
buf = b64_username + ":" + b64_password + ":" + b64_timestamp

key_file = open('/xxx/xxx/NEXTAPI_TEST_public.pem', 'r')
rsa = RSA.importKey(
cipher =
enc = cipher.encrypt(str.encode(str(buf)))
b4_hash = base64.b64encode(enc).decode("utf-8")

headers = {'Accept': 'application/json'}
params = urllib.urlencode({'service': service, 'auth': b4_hash})
connection.request('POST', '/next/' + API_VERSION + '/login', params, headers)
resp = connection.getresponse()

response =
json_data = json.loads(response.decode("utf-8"))

session_key = json_data['session_key'] + ':' + json_data['session_key']
b64_auth = base64.b64encode(bytes(session_key))
headers['Authorization'] = 'Basic '+ b64_auth

#när jag ändrar följande sleep till 2 sekunder eller mer failar anropet nedan. Med sleep på 1 sekund eller mindre får jag som förväntat {"logged_in": true}


connection.request('PUT', '/next/' + API_VERSION + '/login', '', headers)
resp = connection.getresponse()
response =
json_data = json.loads(response.decode("utf-8"))

felmeddelandet jag får om jag väntar mer än 2 sekunder är:
resp = connection.getresponse()
File "/usr/lib/python2.7/", line 1027, in getresponse
File "/usr/lib/python2.7/", line 407, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.7/", line 371, in _read_status
raise BadStatusLine(line)
httplib.BadStatusLine: ''

RE: keep alive tråd - Added by Philip about 4 years ago
exception httplib.BadStatusLine
A subclass of HTTPException. Raised if a server responds with a HTTP status code that we don’t understand.

Kolla debug tools i webbläsaren eller ta en pcap o kolla vad du får för response code.

I övrigt så kan jag rekommendera att du testar e.x Requests paketet (måste installeras tyvärr) och använder requests.Session().
Jag kör det och har en async method som kontrollerar min session samt återansluter om det behövs, fungerar såklart med urllib o dylikt med :)

RE: keep alive tråd - Added by Philip about 4 years ago

Sorry, pcap är ju det enda alternativet av mina förslag...

RE: keep alive tråd - Added by sunh about 1 month ago

The photos related to your <a href="" target="_blank">먹튀검증</a> are amazing. This is the first time I've ever seen a picture of a cool <a href="" target="_blank">꽁머니</a>. Since when did you take pictures of <a href="" target="_blank">토토사이트</a>? It's very cool. And I'm very interested in the material that you have posted so far about <a href="" target="_blank">안전놀이터</a>. It's hard to find data on <a href="" target="_blank">먹튀검증</a>, how did you become an expert? I'm also very interested in <a href="" target="_blank">안전놀이터</a>. I collect a lot of data about <a href="" target="_blank">꽁머니</a> and I have a lot of data about <a href="" target="_blank">스포츠중계</a>. I want to communicate with you. My site names are <a href="" target="_blank">먹튀가디언</a> and <a href="" target="_blank">먹튀보안관</a>. The domain addresses are <a href="" target="_blank">;/a> and <a href="" target="_blank">;/a&gt;. Waiting for a lot of communication. Yes, thank you.

RE: keep alive tråd - Added by sunh about 1 month ago

먹튀검증 Your article was very impressive to me. 먹튀검증 It was unexpected information,안전놀이터 but after reading it like this,토토사이트 I found it very interesting. 꽁머니 Thank you very much. 꽁머니 It was an honor to see this information. 안전놀이터 I should upload similar information on my website. 스포츠중계 Come and check it out for me. In addition, COVID-19 is becoming a problem all over the world these days. 먹튀보안관 I hope there's no harm to you and your family. 먹튀가디언 Thank you

RE: keep alive tråd - Added by sunh about 1 month ago

토토레프리 Hello. First of all, 먹튀검증 thank you for allowing me to read such a good post. I really enjoyed it! 먹튀 This content will be 먹튀검증업체 very helpful to me. I live in another country, but your post impressed me deeply. 먹튀사이트 I wish I had read this a little earlier. 메이저놀이터 You seem to have a great ability to write. I envy it so much. Because I'm actually running a 메이저놀이터 similar site. 사설토토 It's not enough yet. 메이저사설토토 But there are many posts on my site that you might be interested in. Please visit me sometime 사설놀이터 and read my post. 안전놀이터 It must feel interesting. COVID-19 안전놀이터 is becoming a problem all over the world 토토사이트 these days, and I'm worried if you 메이저토토사이트 and your country are okay. I hope there are no big problems. 토토사이트추천 Always be careful and have a nice day today. 토토사이트

RE: keep alive tråd - Added by sunh about 1 month ago

안전놀이터검증및연구센터 Hello, 토토사이트분석전문블로그 I would like to 먹튀검증의새로운패러다임 tell you that I read your post very well. I put a lot of effort into finding this quality article. 안전놀이터 Your writing skills are amazing. 먹튀검증 Are you an expert on this subject? 토토사이트 I think so. 먹튀사이트검증 That's how much your writing 메이저토토사이트 feels professional. 메이저안전놀이터 I hope many high-quality posts like yours 안전한사설토토사이트 will be posted on 공식안전놀이터 the website I run by me. 먹튀검증커뮤니티 If you're curious, 먹튀검증토토사이트 please visit my website as well. 먹튀검증토토 I'm still lacking a lot, 사설안전놀이터] but if you come and point out what I'm lacking, my website will be able to develop further. I'd be very happy if you would. Once again, thank you for writing, and I hope you have a great day today. Thank you.Nowadays,토토사이트검증업체 the weather is getting colder every day토토안전놀이터 , so wear warm clothes and watch out for a cold 확실한먹튀검증 It's really cool "url=]검증토토사이트"/url]. I'd like to know more information. Just like your 안전한먹튀검증 I have 최고의안전놀이터

RE: keep alive tråd - Added by dkfeiskkd 16 days ago

I love your blog post. I have bookmarked your blog in my bookmarks list. I hope you also visit my website. 먹튀검증

RE: keep alive tråd - Added by dkfeiskkd 16 days ago

Your post is really amazing! Please also visit my website to see.무료웹툰