Unable to Save Email Domain

Traceback (most recent call last):
File “/home/administrator/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py”, line 163, in get_incoming_server
email_server.connect()
File “/home/administrator/frappe-bench/apps/frappe/frappe/email/receive.py”, line 43, in connect
return self.connect_imap()
File “/home/administrator/frappe-bench/apps/frappe/frappe/email/receive.py”, line 54, in connect_imap
self.imap.login(self.settings.username, self.settings.password)
File “/usr/lib/python3.5/imaplib.py”, line 582, in login
raise self.error(dat[-1])
imaplib.IMAP4.error: b’[AUTHENTICATIONFAILED] Authentication failed.’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/administrator/frappe-bench/apps/frappe/frappe/email/doctype/email_domain/email_domain.py”, line 76, in on_update
email_account.save()
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 260, in save
return self._save(*args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 294, in _save
self.run_before_save_methods()
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 869, in run_before_save_methods
self.run_method(“validate”)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 765, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 1040, in composer
return composed(self, method, *args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 1023, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 759, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py”, line 66, in validate
self.get_incoming_server()
File “/home/administrator/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py”, line 165, in get_incoming_server
message = e.message.lower().replace(" “,”")
AttributeError: ‘error’ object has no attribute ‘message’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/administrator/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 22, in savedocs
doc.save()
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 260, in save
return self._save(*args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 311, in _save
self.run_post_save_methods()
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 898, in run_post_save_methods
self.run_method(“on_update”)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 765, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 1040, in composer
return composed(self, method, *args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 1023, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 759, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/email/doctype/email_domain/email_domain.py”, line 79, in on_update
frappe.throw(e)
File “/home/administrator/frappe-bench/apps/frappe/frappe/init.py”, line 327, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’)
File “/home/administrator/frappe-bench/apps/frappe/frappe/init.py”, line 312, in msgprint
message_log.append(json.dumps(out))
File “/usr/lib/python3.5/json/init.py”, line 230, in dumps
return _default_encoder.encode(obj)
File “/usr/lib/python3.5/json/encoder.py”, line 198, in encode
chunks = self.iterencode(o, _one_shot=True)
File “/usr/lib/python3.5/json/encoder.py”, line 256, in iterencode
return _iterencode(o, 0)
File “/usr/lib/python3.5/json/encoder.py”, line 179, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: AttributeError(“‘error’ object has no attribute ‘message’”,) is not JSON serializable

Traceback (most recent call last):
File “/home/administrator/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py”, line 163, in get_incoming_server
email_server.connect()
File “/home/administrator/frappe-bench/apps/frappe/frappe/email/receive.py”, line 43, in connect
return self.connect_imap()
File “/home/administrator/frappe-bench/apps/frappe/frappe/email/receive.py”, line 54, in connect_imap
self.imap.login(self.settings.username, self.settings.password)
File “/usr/lib/python3.5/imaplib.py”, line 582, in login
raise self.error(dat[-1])
imaplib.IMAP4.error: b’[AUTHENTICATIONFAILED] Authentication failed.’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/administrator/frappe-bench/apps/frappe/frappe/email/doctype/email_domain/email_domain.py”, line 76, in on_update
email_account.save()
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 260, in save
return self._save(*args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 294, in _save
self.run_before_save_methods()
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 869, in run_before_save_methods
self.run_method(“validate”)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 765, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 1040, in composer
return composed(self, method, *args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 1023, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 759, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py”, line 66, in validate
self.get_incoming_server()
File “/home/administrator/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py”, line 165, in get_incoming_server
message = e.message.lower().replace(" “,”")
AttributeError: ‘error’ object has no attribute ‘message’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/administrator/frappe-bench/apps/frappe/frappe/app.py”, line 62, in application
response = frappe.handler.handle()
File “/home/administrator/frappe-bench/apps/frappe/frappe/handler.py”, line 22, in handle
data = execute_cmd(cmd)
File “/home/administrator/frappe-bench/apps/frappe/frappe/handler.py”, line 55, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/administrator/frappe-bench/apps/frappe/frappe/init.py”, line 942, in call
return fn(*args, **newargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 22, in savedocs
doc.save()
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 260, in save
return self._save(*args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 311, in _save
self.run_post_save_methods()
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 898, in run_post_save_methods
self.run_method(“on_update”)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 765, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 1040, in composer
return composed(self, method, *args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 1023, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 759, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/email/doctype/email_domain/email_domain.py”, line 79, in on_update
frappe.throw(e)
File “/home/administrator/frappe-bench/apps/frappe/frappe/init.py”, line 327, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’)
File “/home/administrator/frappe-bench/apps/frappe/frappe/init.py”, line 312, in msgprint
message_log.append(json.dumps(out))
File “/usr/lib/python3.5/json/init.py”, line 230, in dumps
return _default_encoder.encode(obj)
File “/usr/lib/python3.5/json/encoder.py”, line 198, in encode
chunks = self.iterencode(o, _one_shot=True)
File “/usr/lib/python3.5/json/encoder.py”, line 256, in iterencode
return _iterencode(o, 0)
File “/usr/lib/python3.5/json/encoder.py”, line 179, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: AttributeError(“‘error’ object has no attribute ‘message’”,) is not JSON serializable

You seem to have a bad setting in your email subsystem. Does your server perhaps need imap:143 → imaps:993 port settings change? or smtp:25 → smtps:587
you can find standard ports here

I’m using bluehost.com email server and ERP is deployed on local Ubuntu. The server detail is as follows:
Incoming Server: mail.jade.pk
IMAP Port: 993 POP3 Port: 995
Outgoing Server: mail.jade.pk
SMTP Port: 465

While screenshot is:

Traceback (most recent call last):
File “/home/administrator/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 22, in savedocs
doc.save()
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 260, in save
return self._save(*args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 290, in _save
self.check_if_latest()
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 622, in check_if_latest
where name = %s for update"“”.format(self.doctype), self.name, as_dict=True)
File “/home/administrator/frappe-bench/apps/frappe/frappe/database.py”, line 199, in sql
self._cursor.execute(query, values)
File “/home/administrator/frappe-bench/env/lib/python3.5/site-packages/pymysql/cursors.py”, line 170, in execute
result = self._query(query)
File “/home/administrator/frappe-bench/env/lib/python3.5/site-packages/pymysql/cursors.py”, line 328, in _query
conn.query(q)
File “/home/administrator/frappe-bench/env/lib/python3.5/site-packages/pymysql/connections.py”, line 893, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/administrator/frappe-bench/env/lib/python3.5/site-packages/pymysql/connections.py”, line 1103, in _read_query_result
result.read()
File “/home/administrator/frappe-bench/env/lib/python3.5/site-packages/pymysql/connections.py”, line 1396, in read
first_packet = self.connection._read_packet()
File “/home/administrator/frappe-bench/env/lib/python3.5/site-packages/pymysql/connections.py”, line 1059, in _read_packet
packet.check_error()
File “/home/administrator/frappe-bench/env/lib/python3.5/site-packages/pymysql/connections.py”, line 384, in check_error
err.raise_mysql_exception(self._data)
File “/home/administrator/frappe-bench/env/lib/python3.5/site-packages/pymysql/err.py”, line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.InternalError: (1205, ‘Lock wait timeout exceeded; try restarting transaction’)

Traceback (most recent call last):
File “/home/administrator/frappe-bench/apps/frappe/frappe/app.py”, line 62, in application
response = frappe.handler.handle()
File “/home/administrator/frappe-bench/apps/frappe/frappe/handler.py”, line 22, in handle
data = execute_cmd(cmd)
File “/home/administrator/frappe-bench/apps/frappe/frappe/handler.py”, line 55, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/administrator/frappe-bench/apps/frappe/frappe/init.py”, line 942, in call
return fn(*args, **newargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 22, in savedocs
doc.save()
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 260, in save
return self._save(*args, **kwargs)
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 290, in _save
self.check_if_latest()
File “/home/administrator/frappe-bench/apps/frappe/frappe/model/document.py”, line 622, in check_if_latest
where name = %s for update"“”.format(self.doctype), self.name, as_dict=True)
File “/home/administrator/frappe-bench/apps/frappe/frappe/database.py”, line 199, in sql
self._cursor.execute(query, values)
File “/home/administrator/frappe-bench/env/lib/python3.5/site-packages/pymysql/cursors.py”, line 170, in execute
result = self._query(query)
File “/home/administrator/frappe-bench/env/lib/python3.5/site-packages/pymysql/cursors.py”, line 328, in _query
conn.query(q)
File “/home/administrator/frappe-bench/env/lib/python3.5/site-packages/pymysql/connections.py”, line 893, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/administrator/frappe-bench/env/lib/python3.5/site-packages/pymysql/connections.py”, line 1103, in _read_query_result
result.read()
File “/home/administrator/frappe-bench/env/lib/python3.5/site-packages/pymysql/connections.py”, line 1396, in read
first_packet = self.connection._read_packet()
File “/home/administrator/frappe-bench/env/lib/python3.5/site-packages/pymysql/connections.py”, line 1059, in _read_packet
packet.check_error()
File “/home/administrator/frappe-bench/env/lib/python3.5/site-packages/pymysql/connections.py”, line 384, in check_error
err.raise_mysql_exception(self._data)
File “/home/administrator/frappe-bench/env/lib/python3.5/site-packages/pymysql/err.py”, line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.InternalError: (1205, ‘Lock wait timeout exceeded; try restarting transaction’)

A similar problem was solved here - the service provider had blocked the port - maybe check that using
smtp check

nc -vv outgoing.server 465

IMAP test

nc -vv incoming.server 993

I checked from Bluehost.com and they are saying that all ports are open while results are:

OK, your email settings seem to be OK then.
Next check the mysql - you have an error indicating a transaction problem/delay.

bench mysql
show processlist
show variables like ‘innodb_lock_wait_timeout’;

Could you explain more for understanding and fixation?

Your error shows this…

The email settings seem to be OK, so the next “logical” step would be to check the DB subsystem and see if there is something causing a delay there which results in the timeout.
The commands above will allow you to check the DB and see what is running, and the lock wait parameters

It was an installation issue and @trentmu solved. I’m very thankful to him for his kind support.

1 Like

Facing the same issue can you please help me out?

“Transaction Lock Issue”

Issue Resolved by adding SMTP port (587, 465) in Inbound & Outbound rule in firewall/Security group(AWS).