dtwy2858 2009-03-04 11:16
浏览 30
已采纳

服务器时间的差异

I'm developing a web site which will retrieve SMS messages that have been sent to a gateway. The gateway is accessed via an API, with the requests in the following format:

http://www.smsgateway.com/?login=myusername&password=mypassword&lasttime=1236164238

Notice that I'm having to track the last time messages were downloaded - only messages received after that time are returned.

The problem is that there's a time difference of about 5 minutes between the servers! Here's what's happening:

->User sends SMS; gateway server timestamps it at 11.00am (let's say actual time is 10.55am)

->My server requests all messages sent from 10.56 onwards - receives the above message and adds it to database

->My server requests all messages sent from 10.58 onwards - receives the above message and adds it again, since it is timestamped at 11.00am

->My server sends another request at 11.00 - receives the message and adds it to the database once more

So my problem is that the one original message is being received 3 times.

Changing my server's time is do-able, but not the remote servers.

How can I handle this without checking to see if the message is already in the database?

  • 写回答

2条回答 默认 最新

  • dsoxcj7276 2009-03-04 11:21
    关注

    When you receive the messages sent from 10.56 onwards, Check the last message time: Say 11:00 a.m, Then Next call only send only at 11:00 a.m because you had already received upto 11:00 a.m of server's time. This way you can reduce your polls. Even this will work for when Server's time is in the reverse condition.

    ie) Check for last message's time:

    in the next poll check from last message's time.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 vscode的问题提问
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM