Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    HTTPS POST using urequests.py and Guru Mediation Error

    Scheduled Pinned Locked Moved Issues & Bugs
    guru error
    7 Posts 3 Posters 4.1k Views 7 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D Offline
      danielm
      last edited by danielm

      I am developing LoRa gateway based on LoPy which posts received data to a particular IoT platform. My application always crashes with multiple Guru Meditation Errors, sometimes without automatic restart of LoPy. The crash may happen only after few sent POST requests or after several minutes or even tens of minutes. It is different after each restart (by hardware switch on LoPy). LoPy is running on firmware version 1.6.12.b1.

      I tried to simplify my code and also switched to publicly available server which accepts POST requests over HTTPS.

      urequests.py was downloaded from GitHub:
      https://github.com/micropython/micropython-lib/blob/master/urequests/urequests.py

      Could you please try the code and check if it crashes with your board?

      import network
      import machine
      import urequests
      import time
      
      
      class Simplified():
      	def __init__(self):
      		self.rtc = machine.RTC()
      		self.wlan = network.WLAN(mode=network.WLAN.STA, antenna=network.WLAN.INT_ANT)
      		self.timeSynchonized = False
      
      	def test(self):
      		self.wlan.ifconfig(config='dhcp')
      		self.wlan.connect("<SSID>", auth=(network.WLAN.WPA2, "<PSWD>"))
      
      		while True:
      			self.rtcNow = self.rtc.now()
      
      			if self.wlan.isconnected():
      
      				if not self.timeSynchonized:
      					self.rtc.ntp_sync("pool.ntp.org")
      					self.timeSynchonized = True
      
      				else:
      					data = '{"id": %s, "time": "%s-%02d-%02dT%02d:%02d:%02d.%03d+00:00"}' % (machine.rng(), self.rtcNow[0], self.rtcNow[1], self.rtcNow[2], self.rtcNow[3], self.rtcNow[4], self.rtcNow[5], self.rtcNow[6] // 1000)
      					print(data)
      					try:
      						response = urequests.post("https://posttestserver.com/post.php", data = data)
      						print(response.text)
      					except Exception as e:
      						print(e)
      						time.sleep(1)
      			
      node = Simplified()
      node.test()
      	
      
      1 Reply Last reply Reply Quote 0
      • B Offline
        bucknall
        last edited by

        Hi @danielm,

        Have you tried updating the firmware and trying this again? I've just tried this and it seems to work without issue.

        My only suggestion would be to ensure that the socket opened in the http request is closed before the loop repeats itself.

        Developer Evangelist - Pycom

        1 Reply Last reply Reply Quote 0
        • D Offline
          danielm
          last edited by

          @bucknall

          I am currently running similar code posting requests to a particular IoT platform over HTTPs and the error happens after some number of requests, usually over 100. My FW version is 1.6.13.b1.

          I will try to load simplified code from my first post in this thread and let you know.
          Did you keep it running long enough?

          The socket is closed within urequests.py library when a response is received.

          B 1 Reply Last reply Reply Quote 0
          • B Offline
            bucknall @danielm
            last edited by

            @danielm Ahh yes, you're right! The board restarts after X number of requests...

            Let me raise this with Daniel - This is definitely odd behaviour...

            Developer Evangelist - Pycom

            1 Reply Last reply Reply Quote 0
            • D Offline
              danielm
              last edited by danielm

              @bucknall

              Thanks a lot, we will be waiting for a solution.

              Btw, the board sometimes restarts and works ok, sometimes keeps restarting in a loop and in other cases it does not restart any more.

              J 1 Reply Last reply Reply Quote 0
              • J Offline
                jimpower @danielm
                last edited by

                @danielm Did you end up solving this issue? I am experiencing the same issue will POST several times then board will reboot it seems like maybe a memory issue or to do with the urequests.py however it does POST perfectly for periods of time.

                1 Reply Last reply Reply Quote 0
                • D Offline
                  danielm
                  last edited by

                  @jimpower I think it should work ok with latest releases. However I did not test it for some time.

                  1 Reply Last reply Reply Quote 0

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • 1 / 1
                  • First post
                    Last post

                  Pycom on Twitter

                  Pycom