picoweb commit 973d6cd33841a2ab2457d0f7247fc423824f46b7
uasyncio commit 5149a54f918361d56e3974c1ace8d0a2bad7a086
uasyncio.core commit 4c63ecf5a64d5db5362e940b33b1687d882c38c8
uasyncio.queues commit 614f5e61e9952602ea273ecc0a446f1232ef1d5e
I'm trying to send some form data to my ESP8266. The form contains network configuration information. About 50% of the time I get the all the data as expected, but other times I don't. There is no pattern that I can see to it working or not working. I can submit the form 5 times waiting 10 seconds between each submit and they may all work, fail, or it might be a mixed bag. I'm not a Wireshark expert, but I took a look at the traffic and a working request looked the same as a non-working request to me. Here are the important bits of the Javascript I use to submit the form:
Code: Select all
$("#network_config_form").submit(function(event) {
event.preventDefault();
event.stopImmediatePropagation();
event.stopPropagation();
$.ajax({
url: $(this).prop("action"), // http://192.168.100.100/update_network_config
data: $(this).serialize(),
type: "POST",
timeout: 5000
});
});
Code: Select all
@APP.route('/update_network_config', methods=['GET', 'POST'])
def update_network_config(request, response):
result = {}
if request.method == 'POST':
yield from request.read_form_data()
print('request.__dict__')
print(request.__dict__)
print("")
print('request.form')
print(request.form)
print("")
yield from picoweb.start_response(response)
yield from response.awrite(result)
Code: Select all
request.__dict__
{'path': '/update_network_config', 'headers': {b'Content-Type': b'application/x-www-form-urlencoded; charset=UTF-8', b'Accept': b'*/*', b'Referer': b'http://192.168.100.100/', b'X-Requested-With': b'XMLHttpRequest', b'Accept-Encoding': b'gzip, deflate', b'Origin': b'http://192.168.100.100', b'Accept-Language': b'en-US,en;q=0.9', b'Connection': b'keep-alive', b'User-Agent': b'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/75.0.3770.90 Chrome/75.0.3770.90 Safari/537.36', b'Content-Length': b'121', b'Host': b'192.168.100.100', b'DNT': b'1'}, 'method': 'POST', 'qs': '', 'reader': <StreamReader <socket state=2 timeout=0 incoming=0 off=0> <socket state=2 timeout=0 incoming=0 off=0>>, 'form': {'ssid': ['AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'], 'port': ['8675', '8675'], 'password': ['aaa', 'bbb']}}
request.form
{'ssid': ['AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'], 'port': ['8675', '8675'], 'password': ['aaa', 'bbb']}
Code: Select all
request.__dict__
{'path': '/update_network_config', 'headers': {b'Content-Type': b'application/x-www-form-urlencoded; charset=UTF-8', b'Accept': b'*/*', b'Referer': b'http://192.168.100.100/', b'X-Requested-With': b'XMLHttpRequest', b'Accept-Encoding': b'gzip, deflate', b'Origin': b'http://192.168.100.100', b'Accept-Language': b'en-US,en;q=0.9', b'Connection': b'keep-alive', b'User-Agent': b'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/75.0.3770.90 Chrome/75.0.3770.90 Safari/537.36', b'Content-Length': b'121', b'Host': b'192.168.100.100', b'DNT': b'1'}, 'method': 'POST', 'qs': '', 'reader': <StreamReader <socket state=2 timeout=0 incoming=0 off=0> <socket state=2 timeout=0 incoming=0 off=0>>, 'form': {'ssid': 'AAAAAAAAAAAAAAAAAAAAAAAAAA'}}
request.form
{'ssid': 'AAAAAAAAAAAAAAAAAAAAAAAAAA'}
Any insight as to why this is happening would be much appreciated.