GithubHelp home page GithubHelp logo

Comments (5)

ewheeler avatar ewheeler commented on May 31, 2024

Try checking if both devices (server and android) have their clocks set correctly. The codes are time-based, so if the clocks are too far apart the codes will not match properly.

from android-channel.

knightsamar avatar knightsamar commented on May 31, 2024

So, does this also mean that both should be in the same time zone ?

from android-channel.

nicpottier avatar nicpottier commented on May 31, 2024

The timestamps are UTC, so no, they do not need to be in the same timezone, but they do both need to be correct.

To debug this I would add some prints to:
https://github.com/rapidpro/rapidpro/blob/master/temba/channels/views.py#L216

That's the view that handles syncs and such.

from android-channel.

irak2010 avatar irak2010 commented on May 31, 2024

The problem is you got a difference of time (between your android phone and your computer) > to 15 min. So after i noticed i had a difference of 4 hours, i changed the code to accept the difference of 5 hours.
The code to change is this one https://github.com/rapidpro/rapidpro/blob/master/temba/channels/views.py#L216 (line 239)
original code:
check that the request isn't too old (15 mins)
now = time.time()
if abs(now - int(request_time)) > 60 * 15:
return HttpResponse(status=401, content='{ "error_id": 3, "error": "Old Request", "cmds":[] }')

changed code:
now = time.time()
if abs(now - int(request_time)) > 60 * 300:
print "DIFF:%s" % (now - int(request_time))
print "NOW: %s" % datetime.fromtimestamp(int(now)).strftime('%Y-%m-%d %H:%M:%S')
print "REQUEST TIME %s" % datetime.fromtimestamp(int(request_time)).strftime('%Y-%m-%d %H:%M:%S')
print "DIFFERENT TIME (old request)"
return HttpResponse(status=401, content='{ "error_id": 3, "error": "Old Request", "cmds":[] }')

from android-channel.

nicpottier avatar nicpottier commented on May 31, 2024

This is by design to prevent replay attacks. There's no valid scenario where your phone should be more than 15 minutes off from your server, it will cause headaches down the line.

from android-channel.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.