ok24601 / etoro-api

etoro trading REST API
ISC License
100 stars 49 forks source link

Fix startup crash when running in Docker container #31

Closed mortenscheel closed 3 years ago

mortenscheel commented 3 years ago

After looking at the stack traces I think I've figured out why the app would sometimes crash during startup when running in a Docker container.

Every time it crashed, it was on this line: https://github.com/ok24601/etoro-api/blob/3cbaadb9c22f5510007609fee153afe6bf9a2be3/src/main/kotlin/ok/work/etoroapi/client/browser/EtoroBrowserContext.kt#L52-L53

I guess it sometimes takes more than 2 seconds to perform the login when running in Docker container with limited resources.

This change will try to get the login-token once every seconds, for up to 5 seconds, before giving up. I've also added a check that throws an exception if LOGIN/PASSWORD is missing - just to provide a meaningful error message.

ok24601 commented 3 years ago

Thanks again friend. It's really impresive how fast you can work.


От: Morten Scheel notifications@github.com Отправлено: 15 февраля 2021 г. 21:51 Кому: ok24601/etoro-api etoro-api@noreply.github.com Копия: Subscribed subscribed@noreply.github.com Тема: [ok24601/etoro-api] Fix startup crash when running in Docker container (#31)

After looking at the stack traces I think I've figured out why the app would sometimes crash during startup when running in a Docker container.

Every time it crashed, it was on this line:

etoro-api/src/main/kotlin/ok/work/etoroapi/client/browser/EtoroBrowserContext.kthttps://github.com/ok24601/etoro-api/blob/3cbaadb9c22f5510007609fee153afe6bf9a2be3/src/main/kotlin/ok/work/etoroapi/client/browser/EtoroBrowserContext.kt#L52-L53

Lines 52 to 53 in 3cbaadb</ok24601/etoro-api/commit/3cbaadb9c22f5510007609fee153afe6bf9a2be3>

Thread.sleep(2000) token = driver.executeScript("return JSON.parse(atob(window.localStorage.loginData)).stsData_app_1.accessToken;") as String

I guess it sometimes takes more than 2 seconds to perform the login when running in Docker container with limited resources.

This change will try to get the login-token once every seconds, for up to 5 seconds, before giving up. I've also added a check that throws an exception if LOGIN/PASSWORD is missing - just to provide a meaningful error message.


You can view, comment on, or merge this pull request online at:

https://github.com/ok24601/etoro-api/pull/31

Commit Summary

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/ok24601/etoro-api/pull/31, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADHNNVQ3N75YNW4R2IIMBGTS7F3MXANCNFSM4XVHIPFQ.

mortenscheel commented 3 years ago

Thanks buddy. Before I discovered this project I was looking at all the ajax requests, and wondered how I could extract the data I need automatically. So this is exactly what I need 😀.

I'm working on building a frontend with all the stats and charts I wish eToro offered.

I've been waiting for an official API key for months. Do you know if they've just stopped accepting new developer accounts?

ok24601 commented 3 years ago

Hi

Nope. I also requested official API but never heared back from them.


От: Morten Scheel notifications@github.com Отправлено: 16 февраля 2021 г. 0:26 Кому: ok24601/etoro-api etoro-api@noreply.github.com Копия: ok24601 oleh_22_08@outlook.com; State change state_change@noreply.github.com Тема: Re: [ok24601/etoro-api] Fix startup crash when running in Docker container (#31)

Thanks buddy. Before I discovered this project I was looking at all the ajax requests, and wondered how I could extract the data I need automatically. So this is exactly what I need 😀.

I'm working on building a frontend with all the stats and charts I wish eToro offered.

I've been waiting for an official API key for months. Do you know if they've just stopped accepting new developer accounts?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/ok24601/etoro-api/pull/31#issuecomment-779474623, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADHNNVQKWOA3G6EXJLLDAO3S7GNSPANCNFSM4XVHIPFQ.