webdjoe / pyvesync_v2

Python Library for controlling vesync API for all etekcity smart outlets, switches and bulbs and Levoit Air Purifier
MIT License
30 stars 17 forks source link

Lof In fails with MS 2017 SQL Python Script #17

Closed harrynicol closed 3 years ago

harrynicol commented 4 years ago

Can log into VeSync with Visual Studio and Jupiter Notebooks but running the same script on MS 2017 SQL Server VeSync log in fails. Any ideas?

webdjoe commented 4 years ago

What error are you getting? There should be a log entry that lets you narrow it down to an incorrect password or a failed request

harrynicol commented 4 years ago

Hi Joe,

Impressed by the Saturday night reply, thanks.

Simple Log In Script

EXEC sp_execute_external_script @language = N'Python', @script = N' from pyvesync import VeSync manager = VeSync("harrynicol@nc.rr.com", "xxxxxxxxxx") manager.login() ' Error returned

STDERR message(s) from external script: 2020-01-12 06:14:42,436 - ERROR - HTTPSConnectionPool(host='smartapi.vesync.com', port=443): Max retries exceeded with url: /cloud/v1/user/login (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x00000124C4B3FBE0>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions',)) 2020-01-12 06:14:42,440 - ERROR - Error logging in with username and password Other

Pyvesync-v2 is the same SQL Log is as below 01/12/2020 06:21:14,spid56,Unknown,SQL Server received abort message and abort execution for major error : 18 and minor error : 42

Many thanks

Harry Nicol 8768 Wildwood Links Raleigh NC 27613 919-757-711

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10

From: Joe Trabulsymailto:notifications@github.com Sent: Saturday, January 11, 2020 7:47 PM To: webdjoe/pyvesync_v2mailto:pyvesync_v2@noreply.github.com Cc: Harry Nicolmailto:harrynicol@thescottishedge.com; Authormailto:author@noreply.github.com Subject: Re: [webdjoe/pyvesync_v2] Lof In fails with MS 2017 SQL Python Script (#17)

What error are you getting? There should be a log entry that lets you narrow it down to an incorrect password or a failed request

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/webdjoe/pyvesync_v2/issues/17?email_source=notifications&email_token=AI56HHE2Z4FAPN5ETKPWLYDQ5JSAFA5CNFSM4KFUMCV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIWOSQA#issuecomment-573368640, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AI56HHHM3HSJBLVS2OO7ZZLQ5JSAFANCNFSM4KFUMCVQ.

webdjoe commented 4 years ago

That usually means a firewall is blocking the port. On my computer all outgoing connections are blocked that aren't allowed by a rule. I get that error when running in a new python virtual environment that I haven't allowed through. Check your firewall settings and make sure that python executable running the script is allowed through

harrynicol commented 4 years ago

Disabled the firewall on the server hosting the SQL instance that runs the MI python scripts. That removed the error. As u would expect, as you have, few open ports as necessary. Now the problem is finding the port to open. Will work on this tomorrow and will let u know. Still but if a puzzle. On my workstation that also runs MS SQL server python scripts it fails but Visua Studio and Jupiter notebooks run with out error

Harry Nicol 8768 Wildwood Links Raleigh NC 27613 919-757-1711 harrynicol@thescottishedge.com


From: Joe Trabulsy notifications@github.com Sent: Sunday, January 12, 2020 1:54:12 PM To: webdjoe/pyvesync_v2 pyvesync_v2@noreply.github.com Cc: Harry Nicol harrynicol@thescottishedge.com; Author author@noreply.github.com Subject: Re: [webdjoe/pyvesync_v2] Lof In fails with MS 2017 SQL Python Script (#17)

That usually means a firewall is blocking the port. On my computer all outgoing connections are blocked that aren't allowed by a rule. I get that error when running in a new python virtual environment that I haven't allowed through. Check your firewall settings and make sure that python executable running the script is allowed through

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/webdjoe/pyvesync_v2/issues/17?email_source=notifications&email_token=AI56HHBQKV7EQ4UJMA65HDLQ5NRNJA5CNFSM4KFUMCV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIXBMCY#issuecomment-573445643, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AI56HHGAQ6IP2PMSO6T4DIDQ5NRNJANCNFSM4KFUMCVQ.

webdjoe commented 4 years ago

I'm guessing the server is running windows. Just allow that python executable installed with sql server outgoing on port 443

harrynicol commented 4 years ago

Resolved. Windows firewal log was showing Deny for 443 when running python from sql instance and Allow for 443 from Visual Studio. That did not make any sense as python was enabled thro the firewall. Had to be something else. In the firewall R access for the SQL instance was blocked but no mention of python. So worth a try so enabled access and bingo it also worked for python.

Thanks for the input and thanks for doing the API. Now I can complete my MI project

Harry Nicol 8768 Wildwood Links Raleigh NC 27613 919-757-1711 harrynicol@thescottishedge.com


From: Joe Trabulsy notifications@github.com Sent: Sunday, January 12, 2020 10:02:25 PM To: webdjoe/pyvesync_v2 pyvesync_v2@noreply.github.com Cc: Harry Nicol harrynicol@thescottishedge.com; Author author@noreply.github.com Subject: Re: [webdjoe/pyvesync_v2] Lof In fails with MS 2017 SQL Python Script (#17)

I'm guessing the server is running windows. Just allow that python executable installed with sql server outgoing on port 443

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/webdjoe/pyvesync_v2/issues/17?email_source=notifications&email_token=AI56HHEHHNNY75KTELRUJODQ5PKUDA5CNFSM4KFUMCV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIXMYII#issuecomment-573492257, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AI56HHDSWMBZUELAGDGRX5LQ5PKUDANCNFSM4KFUMCVQ.