Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    3.2 JSON Parse error: Unrecognized token '<' Password bug

    Scheduled Pinned Locked Moved
    Beta Firmware
    8
    58
    3.9k
    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.
    • Phaedruxundefined
      Phaedrux Moderator
      last edited by

      My last suggestion is to manually replace the contents of the /www folder with a fresh set from https://github.com/Duet3D/RepRapFirmware/releases/download/3.2/DuetWebControl-SD.zip

      And if that doesn't work, try a fresh SD card.

      And if that doesn't work, wait for chrishamm

      Z-Bot CoreXY Build | Thingiverse Profile

      Charlieundefined 1 Reply Last reply Reply Quote 0
      • Charlieundefined
        Charlie @Phaedrux
        last edited by

        @Phaedrux

        Unfortunately manually replacing the www folder did not change anything, and neither did a new SD card. Thank you for your input though!

        1 Reply Last reply Reply Quote 0
        • Charlieundefined
          Charlie @chrishamm
          last edited by

          @chrishamm

          If you have any insight, I would greatly appreciate it.

          chrishammundefined 1 Reply Last reply Reply Quote 0
          • chrishammundefined
            chrishamm administrators @Charlie
            last edited by

            @Charlie Some response doesn't seem right, no valid JSON should start with '<' so you're getting an error. Try to open the developer console with F12 and check the log for further details. You should be able to see an error trace in there.

            What browser are you using? Can you open DWC from a different device?

            Duet software engineer

            Charlieundefined 1 Reply Last reply Reply Quote 0
            • Charlieundefined
              Charlie @chrishamm
              last edited by

              @chrishamm

              Thank you for your response.

              I opened the developer console in Safari (Develop > Show Web Inspector > Console). I found the following errors and warnings:

              Screen Shot 2021-01-08 at 12.58.28 PM.png

              Im currently using Safari.

              1 Reply Last reply Reply Quote 0
              • Charlieundefined
                Charlie
                last edited by

                The first error does not seem to be the cause of the issue, and was resolved by inserting a blank "dwc-plugins.json" file in the sys/ folder using DWC.

                The subsequent errors seem to be the cause of the issue. Ive diffchecked both the "pollconnector.js" and the "BaseConnector.js" files against the files in GitHub and they appear to be identical. Im pretty out of my depth when it comes to coding, so any help would be greatly appreciated.

                1 Reply Last reply Reply Quote 0
                • Phaedruxundefined
                  Phaedrux Moderator
                  last edited by

                  Can you test with Chrome just to see if it's isolated to safari on your machine? What MacOS and Safari version are you running?

                  Z-Bot CoreXY Build | Thingiverse Profile

                  Charlieundefined 2 Replies Last reply Reply Quote 0
                  • Sindariusundefined
                    Sindarius
                    last edited by

                    The 401 error would mean the < you are getting is because it's sending an HTML 401 error page response.

                    What happens if you take out the M551 in your config? Maybe there is an issue going on with passwords?

                    1 Reply Last reply Reply Quote 1
                    • Charlieundefined
                      Charlie @Phaedrux
                      last edited by

                      @Phaedrux

                      I will try to see if I can replicate the issue on Chrome, though its difficult to reliably replicate the issue. I am using macOS Big Sur 11.1 and Safari 14.0.2 (most up to date I believe).

                      1 Reply Last reply Reply Quote 0
                      • alankilianundefined
                        alankilian
                        last edited by alankilian

                        (I'm NOT a JavaScript guy, so....))

                        It looks like the code is trying to parse a JSON tesponse, but the response is not JSON, it's text.

                        I notice in PollConnector.js this code:

                        				if (xhr.status >= 200 && xhr.status < 300) {
                        					if (responseType === 'json') {
                        						try {
                        							if (!xhr.responseText) {
                        								resolve(null);
                        							} else {
                        								resolve(JSON.parse(xhr.responseText));
                        							}
                        						} catch (e) {
                        							reject(e);
                        						}
                        					} else {
                        						resolve(xhr.response);
                        					}
                        

                        But in BaseConnector.js I see this code:

                        				if (xhr.status >= 200 && xhr.status < 300) {
                        					try {
                        						if (!xhr.responseText) {
                        							resolve(null);
                        						} else {
                        							resolve(JSON.parse(xhr.responseText));
                        						}
                        					} catch (e) {
                        						reject(e);
                        					}
                        

                        Maybe if you use the code from PollConnector.js in BaseConnector.js you'll fix the issue.

                        SeemeCNC Rostock Max V3 converted to V3.2 with a Duet2 Ethernet Firmware 3.2 and SE300

                        1 Reply Last reply Reply Quote 0
                        • Charlieundefined
                          Charlie @Phaedrux
                          last edited by

                          @Phaedrux

                          It appears as though this is NOT occurring in Chrome, though Ive been having issues replicating the error recently.

                          1 Reply Last reply Reply Quote 0
                          • Phaedruxundefined
                            Phaedrux Moderator
                            last edited by

                            Wouldn't be the first time Safari has behaved oddly.

                            Z-Bot CoreXY Build | Thingiverse Profile

                            Charlieundefined 1 Reply Last reply Reply Quote 0
                            • Charlieundefined
                              Charlie @Phaedrux
                              last edited by Charlie

                              @Phaedrux

                              Hahaha! Very true.

                              I am testing out the solution by @Sindarius and I will report back the results.

                              1 Reply Last reply Reply Quote 0
                              • Charlieundefined
                                Charlie
                                last edited by

                                @Sindarius

                                Your solution appears to have worked! I deleted M551 and no more error messages in Safari.

                                1 Reply Last reply Reply Quote 1
                                • Charlieundefined
                                  Charlie
                                  last edited by

                                  @alankilian

                                  Thank you so much for your response, but I have no clue how I would go about changing this, as I have no clue where these files (don't even know if the files sit on the Duet, lol).

                                  alankilianundefined 1 Reply Last reply Reply Quote 0
                                  • alankilianundefined
                                    alankilian @Charlie
                                    last edited by

                                    @Charlie "Ive diffchecked both the "pollconnector.js" and the "BaseConnector.js" files against the files in GitHub and they appear to be identical. Im pretty out of my depth when it comes to coding, so any help would be greatly appreciated."

                                    Oh, I figured if you checked those files you'd be ready-to-go. My machine is at the lab and I haven't been going in there due to COVID-19, so I can't check.

                                    I don't know where the files are either, but the .zip file has them in: store\machine\connector

                                    Is that a place on your Duet?

                                    SeemeCNC Rostock Max V3 converted to V3.2 with a Duet2 Ethernet Firmware 3.2 and SE300

                                    Charlieundefined 1 Reply Last reply Reply Quote 0
                                    • chrishammundefined
                                      chrishamm administrators
                                      last edited by

                                      @Charlie Thanks for the log, I'll try to reproduce this in Safari but I am surprised it tries to parse invalid JSON at some point - even because it should never attempt to parse anything once it gets back HTTP code 401.

                                      @alankilian BaseConnector is the base class of PollConnector and that particular function is only used when connecting. The JS files are bundled by Webpack into very few files to accelerate the initial page load.

                                      Duet software engineer

                                      1 Reply Last reply Reply Quote 0
                                      • Charlieundefined
                                        Charlie @alankilian
                                        last edited by

                                        @alankilian

                                        This is what I have on the SD card, and a search of the file names turned up nothing. I could be looking in the wrong place though, since I have no clue where those files sit, or how to modify them.

                                        Screen Shot 2021-01-09 at 12.13.10 PM.png

                                        1 Reply Last reply Reply Quote 0
                                        • alankilianundefined
                                          alankilian
                                          last edited by

                                          @chrishamm said in 3.2 JSON Parse error: Unrecognized token '<':

                                          The JS files are bundled by Webpack into very few files to accelerate the initial page load.

                                          I don't know what this message from @chrishamm means.

                                          I'm guessing that when the firmware is built a bunch of these files get packed together somehow, renamed and put somewhere on the Duet.

                                          Sorry I'm not better versed in the Internets-part of 3D printing.

                                          SeemeCNC Rostock Max V3 converted to V3.2 with a Duet2 Ethernet Firmware 3.2 and SE300

                                          Charlieundefined 1 Reply Last reply Reply Quote 0
                                          • Charlieundefined
                                            Charlie @alankilian
                                            last edited by

                                            @alankilian

                                            Neither do I.

                                            No worries! You've been super helpful, and way more knowledgeable than myself! I greatly appreciate your time.

                                            Since changing the browser or removing the password GCode fixed this issue, Im super happy.

                                            1 Reply Last reply Reply Quote 1
                                            • First post
                                              Last post
                                            Unless otherwise noted, all forum content is licensed under CC-BY-SA