Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always get TimeoutError while invoking place_order in Google Cloud Functions #149

Open
AugTH opened this issue Aug 21, 2023 · 9 comments
Open

Comments

@AugTH
Copy link

AugTH commented Aug 21, 2023

shioaji version: 1.1.11

Hi there, I found that I always get TimeoutError while invoking place_order() in Google Cloud Functions, after checking the logs, looks like it dues to the timezone in the cloud instance is UTC, which is 8 hours later than Taipei (CST timezone), I guess this is the reason of TimeoutError.

Since I didn't find an easy way to change the time zone of the cloud instance, guessing the simplest fix is to always convert the time with the CST timezone before sending the request, could you please take a look at this issue?

Your API is such a great work, it would be better if it works fine in the cloud :)

@AugTH
Copy link
Author

AugTH commented Aug 21, 2023

BTW, it works fine in my local development laptop, I just simply deploy it to Google Cloud and the region of the cloud instance is asia-east1 which is supposed to be located in Changhua.

@Pofatoezil
Copy link

@AugThWu
Hello, I've deployed the function in the asia-east1 region. However, I keep encountering a TimeoutError when I execute the logout function. Have you ever encountered a similar issue? Thank you.

Traceback (most recent call last):
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/app.py", line 2190, in wsgi_app
response = self.full_dispatch_request()
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/app.py", line 1486, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/functions_framework/init.py", line 130, in view_func
return function(request._get_current_object())
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/functions_framework/init.py", line 110, in wrapper
return func(*args, **kwargs)
File "/workspace/main.py", line 78, in hello_http
api.logout()
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/shioaji/shioaji.py", line 343, in logout
res = self._solace.logout()
File "shioaji/backend/solace/api.pyx", line 573, in shioaji.backend.solace.api.SolaceAPI.logout
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/pysolace/init.py", line 278, in request
raise TimeoutError(

@AugTH
Copy link
Author

AugTH commented Sep 1, 2023

Hi @Pofatoezil

If I remember correctly, I got TimeoutError while invoking place_order thus hadn't invoked logout yet, so I have no idea if logout has the same problem. I could paste the call stack here as well if necessary :)

@Pofatoezil
Copy link

Hi @AugThWu
My English isn't very good, so to make sure I use the right words, I'll reply to you in Chinese.

最近我為了將TradingView 交易策略的webhook alerts 串接到自動下單,所以研究將shioaji api放到google cloud function中
目前測試place_order,沒有遇到問題。
我使用python 3.8
requirement.txt:

functions-framework==3.*
requests
google-cloud-storage
shioaji==1.1.12
pydantic==1.10.11

但仍然有許多狀況:
1.有時候api.login()會出現Timeout error, 發生這個問題之後,一定要重新部署才會恢復正常
2. api.logout()則是必定會出現Timeout error。
但我從本地端使用api.usage()觀察連線情況,連線是有登出的。
所以我用下面的方式來避免一直出現Timeour error

try:
    api.logout()
except TimeoutError:
    pass

希望以上資訊能幫助你排除狀況

@cow5566bad
Copy link

Any follow up on this issue? I am using shioaji==1.2.2 and I have TimeoutError occasionally when calling api.login function on GCP Cloud Functions. I have no issue on my laptop.

@a0911802160
Copy link

Any follow up on this issue? I am using shioaji==1.2.2 and I have TimeoutError occasionally when calling api.login function on GCP Cloud Functions. I have no issue on my laptop.

I got the same issue, any update on it?

@JinanWu
Copy link

JinanWu commented Feb 17, 2024

我的狀況是在 login 就出現這樣的問題。

@jasonlin0189impv
Copy link

想請問有解決方法了嗎?因為 gcp serveless 服務沒辦法修改系統時間,python 使用 pytz 改時區也沒辦法解決

@Pofatoezil
Copy link

@jasonlin0189impv 選擇台灣區域的Server (Asia east 1)來部屬,但不是每次都可以的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants