libracore / WooCommerceConnector

Integration App for ERPNext to connect to WooCommerce
Other
85 stars 149 forks source link

InsecureRequestWarning #35

Open littlebunyip opened 4 years ago

littlebunyip commented 4 years ago

Hello and thanks for sharing.

The other day this error (gunicorn web.error.log in DEBUG mode) started to come up and now causes a timeout when submitting any documents that make a stock transaction (eg. Submitting a Delivery Note) and woocommerce syncing has stopped working.

/home/-------/frappe-bench/env/lib/python3.7/site-packages/urllib3/connectionpool.py:1004:
InsecureRequestWarning: Unverified HTTPS request is being made to host '----------'.
Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning,

The remote woocommerce host has a valid ssl certificate but my 'self hosted' version of erpnext runs with a self signed certificate.

If I disable this app by un-setting the 'Enable Woocommerce' check box at the top of the config doctype, I can then submit any documents with stock entries. I have read the link that the error points to, but do not know where to add the suggested python code to this apps code.

ERPNext: v13.x.x-develop () (develop) Frappe Framework: v13.x.x-develop () (develop) Lb Erpnext Dev: v0.0.1 (master) Monitor: v0.1.0 (master) WooCommerce Connector: v1.5.0 (master)

littlebunyip commented 4 years ago

Wondering if anyone might have any ideas about how I may fix this issue or any more tips for me to gather debug info?

lasalesi commented 4 years ago

Not sure about the correlation of WooCommerce with getting stuck on stock entries and the like. The hourly sync runs an hourly background process to sync, but has no impact on submitting documents...

For now, the WooCommerceConnector is not yet tested against v13 of ERPNext (still beta). I think the timeout on submit has a different origin, but still, do check why you are getting an insecure https warning. Maybe some routing issue?

lasalesi commented 4 years ago

Try to enable verify_ssl in the WooCommerce Config...

littlebunyip commented 4 years ago

Thanks for the reply. If I enable verify_ssl I get the following error:

App Versions

{
    "erpnext": "13.0.0-dev",
    "frappe": "13.0.0-dev",
    "lb_erpnext_dev": "0.0.1",
    "monitor": "0.1.0",
    "woocommerceconnector": "1.5.0"
}

Route

Form/WooCommerce Config/WooCommerce Config

Error Report

Traceback (most recent call last):
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 21, in savedocs
    doc.save()
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/model/document.py", line 285, in save
    return self._save(*args, **kwargs)
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/model/document.py", line 320, in _save
    self.run_before_save_methods()
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/model/document.py", line 930, in run_before_save_methods
    self.run_method("validate")
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/model/document.py", line 831, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/model/document.py", line 1116, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/model/document.py", line 1099, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/model/document.py", line 825, in 
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/spidyip/frappe-bench/apps/woocommerceconnector/woocommerceconnector/woocommerceconnector/doctype/woocommerce_config/woocommerce_config.py", line 17, in validate
    self.validate_access()
  File "/home/spidyip/frappe-bench/apps/woocommerceconnector/woocommerceconnector/woocommerceconnector/doctype/woocommerce_config/woocommerce_config.py", line 27, in validate_access
    "api_secret": self.get_password(fieldname='api_secret',raise_exception=False), "woocommerce_url": self.woocommerce_url, "verify_ssl": self.verify_ssl})
  File "/home/spidyip/frappe-bench/apps/woocommerceconnector/woocommerceconnector/woocommerce_requests.py", line 61, in get_request
    return get_request_request(path, settings).json()
  File "/home/spidyip/frappe-bench/apps/woocommerceconnector/woocommerceconnector/woocommerce_requests.py", line 47, in get_request_request
    r = wcapi.get(path)
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/woocommerce/api.py", line 108, in get
    return self.__request("GET", endpoint, None, **kwargs)
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/woocommerce/api.py", line 103, in __request
    **kwargs
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 654, in urlopen
    conn = self._get_conn(timeout=pool_timeout)
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 274, in _get_conn
    return conn or self._new_conn()
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 984, in _new_conn
    return self._prepare_conn(conn)
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 937, in _prepare_conn
    assert_fingerprint=self.assert_fingerprint,
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/urllib3/connection.py", line 295, in set_cert
    self.ca_certs = ca_certs and os.path.expanduser(ca_certs)
  File "/home/spidyip/frappe-bench/env/lib/python3.7/posixpath.py", line 235, in expanduser
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not int

Traceback (most recent call last):
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/app.py", line 64, in application
    response = frappe.api.handle()
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/api.py", line 58, in handle
    return frappe.handler.handle()
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/handler.py", line 30, in handle
    data = execute_cmd(cmd)
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/handler.py", line 69, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/__init__.py", line 1093, in call
    return fn(*args, **newargs)
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 21, in savedocs
    doc.save()
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/model/document.py", line 285, in save
    return self._save(*args, **kwargs)
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/model/document.py", line 320, in _save
    self.run_before_save_methods()
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/model/document.py", line 930, in run_before_save_methods
    self.run_method("validate")
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/model/document.py", line 831, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/model/document.py", line 1116, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/model/document.py", line 1099, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/spidyip/frappe-bench/apps/frappe/frappe/model/document.py", line 825, in 
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/spidyip/frappe-bench/apps/woocommerceconnector/woocommerceconnector/woocommerceconnector/doctype/woocommerce_config/woocommerce_config.py", line 17, in validate
    self.validate_access()
  File "/home/spidyip/frappe-bench/apps/woocommerceconnector/woocommerceconnector/woocommerceconnector/doctype/woocommerce_config/woocommerce_config.py", line 27, in validate_access
    "api_secret": self.get_password(fieldname='api_secret',raise_exception=False), "woocommerce_url": self.woocommerce_url, "verify_ssl": self.verify_ssl})
  File "/home/spidyip/frappe-bench/apps/woocommerceconnector/woocommerceconnector/woocommerce_requests.py", line 61, in get_request
    return get_request_request(path, settings).json()
  File "/home/spidyip/frappe-bench/apps/woocommerceconnector/woocommerceconnector/woocommerce_requests.py", line 47, in get_request_request
    r = wcapi.get(path)
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/woocommerce/api.py", line 108, in get
    return self.__request("GET", endpoint, None, **kwargs)
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/woocommerce/api.py", line 103, in __request
    **kwargs
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 654, in urlopen
    conn = self._get_conn(timeout=pool_timeout)
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 274, in _get_conn
    return conn or self._new_conn()
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 984, in _new_conn
    return self._prepare_conn(conn)
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 937, in _prepare_conn
    assert_fingerprint=self.assert_fingerprint,
  File "/home/spidyip/frappe-bench/env/lib/python3.7/site-packages/urllib3/connection.py", line 295, in set_cert
    self.ca_certs = ca_certs and os.path.expanduser(ca_certs)
  File "/home/spidyip/frappe-bench/env/lib/python3.7/posixpath.py", line 235, in expanduser
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not int
littlebunyip commented 4 years ago

I just tried entering the code at https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings in a python console by running the following:

spidyip@littlebunyip:~/frappe-bench/config$ bench --site littlebunyip.local console
Apps in this namespace:
frappe, erpnext, lb_erpnext_dev, monitor, woocommerceconnector

In [1]: import certifi                                                                                                                 

In [2]: import urllib3                                                                                                                 

In [3]: http = urllib3.PoolManager( 
   ...: cert_reqs='CERT_REQUIRED', 
   ...: ca_certs="/etc/ssl/certs/nginx-selfsigned.crt" 
   ...: ) 

which points to my self_signed certificate directly. Still the warning. I then ran the code:

spidyip@littlebunyip:~/frappe-bench/config$ bench --site littlebunyip.local console
Apps in this namespace:
frappe, erpnext, lb_erpnext_dev, monitor, woocommerceconnector

In [1]: import certifi                                                                                                                 

In [2]: import urllib3                                                                                                                 

In [3]: http = urllib3.PoolManager( 
   ...: cert_reqs='CERT_REQUIRED', 
   ...: ca_certs=certifi.where()
   ...: ) 

Both had no difference. Still the warnings and the timeouts on submitting documents that have stock transactions. Job Card entries and even Sales Orders can be submitted but Delivery Notes and Stock Entries when finishing Work Orders will not submit.

If you think it may be worthwhile, where in the Woocommerce Config code would I be able to try entering the above code?

alphaomegaphi commented 7 months ago

Hey @littlebunyip were you able to solve this issue? I'm facing the same problem.

littlebunyip commented 7 months ago

No sorry. I am no longer using woocommerce and am moving completely away from wordpress.