# Moku:go "Unknown exception. Status code:504"

**URL:** <https://forum.liquidinstruments.com/t/moku-go-unknown-exception-status-code-504/840>\
**Category:** Moku:Go\
**Created:** [November 8, 2023, 3:07pm UTC](https://forum.liquidinstruments.com/t/moku-go-unknown-exception-status-code-504/840 "2023-11-08T15:07:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![User\_one](https://avatars.discourse-cdn.com/v4/letter/u/e480ec/32.png) [@User\_one](https://forum.liquidinstruments.com/u/User_one)\
**Post date:** [November 8, 2023, 3:07pm UTC](https://forum.liquidinstruments.com/t/moku-go-unknown-exception-status-code-504/840/1 "2023-11-08T15:07:13Z")

</div>

Hello Everyone,

Following the code for “One port method” using the frequency response analyzer posted at [https://knowledge.liquidinstruments.com/en\_US/meauring-impedance-with-mokugo-part-1](https://knowledge.liquidinstruments.com/en_US/meauring-impedance-with-mokugo-part-1) and running Moku:go firmware version 587 I get:

“Exception: Unknown exception. Status code:504”

This appears to be thrown as a result of taking a single sweep via start\_sweep(single=True). This is not a result of get\_data timeout as the sweep takes far less time than the default 60 second time out. Placing a pause via time.sleep does not help. The code will run if I remove the single=True request, however any attempt to stop the sweep [start\_sweep(); time.sleep(1); stop\_sweep();] will result in the same error when get\_data() is called.

In the case where I simply leave the sweep running, start\_sweep(), it is hit or miss. Half the time I get an error in the definition of the magnitude dBm = ‘nan’. This is because the later part of the magnitude array is filled with ‘nan’ values. Possibly the get\_data() in this case grabs an incomplete sweep which is constantly looping.

If this is a connectivity issue, I have tested via USB connection as well as Access Point and get the same issue.

---

<div class="post-metadata">

**Author:** ![nadia](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.liquidinstruments.com/nadia/32/315_2.png) [@nadia](https://forum.liquidinstruments.com/u/nadia)\
**Post date:** [November 15, 2023, 7:11am UTC](https://forum.liquidinstruments.com/t/moku-go-unknown-exception-status-code-504/840/2 "2023-11-15T07:11:25Z")

</div>

Hello,

The most reliable solution to this issue would be to start the sweep without single sweep mode enabled, then enable wait\_complete when getting the data:

> ```
> i.start_sweep()
> frame = i.get_data(wait_complete=True)
> 
> ```

Setting wait\_complete will ensure the data is free of those ‘nan’ values. This is less suitable for longer sweep times as it often takes twice as long as the estimated sweep time.

---

<div class="post-metadata">

**Author:** ![nwood](https://avatars.discourse-cdn.com/v4/letter/n/ce73a5/32.png) [@nwood](https://forum.liquidinstruments.com/u/nwood)\
**Post date:** [November 21, 2023, 3:40pm UTC](https://forum.liquidinstruments.com/t/moku-go-unknown-exception-status-code-504/840/3 "2023-11-21T15:40:29Z")

</div>

Hello, I have also run into this issue with the 504 error and the solution you offered there does work. As you mentioned though, it is less ideal for longer sweep times. Do you know of any other alternatives when dealing with longer sweeps? Thanks.

---

<div class="post-metadata">

**Author:** ![nadia](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.liquidinstruments.com/nadia/32/315_2.png) [@nadia](https://forum.liquidinstruments.com/u/nadia)\
**Post date:** [November 22, 2023, 2:24am UTC](https://forum.liquidinstruments.com/t/moku-go-unknown-exception-status-code-504/840/4 "2023-11-22T02:24:36Z")

</div>

There is currently an issue with the Moku:Go and retrieving a single sweep after resetting the FRA, i.e. connecting via the API. After looking further into the behaviour of sweep times on Moku:Go it appears it only takes twice as long as the estimated sweep time on the first call, this is a bug we will be fixing. Until then, for longer sweep times it may be best to retrieve data from a shorter sweep, after connecting to the device, then running the desired settings with single sweep.

For example:

```auto
# Quick Sweep (a few seconds)
i.set_sweep(start_frequency=6e4, stop_frequency=100, num_points=256,
          averaging_time=1e-6, settling_time=1e-6, averaging_cycles=1, settling_cycles=1)
i.start_sweep()
frame = i.get_data(wait_complete=True)
# Desired Sweep (run time matches the estimated sweep time)
i.set_sweep(start_frequency=6e4, stop_frequency=100, num_points=256,
          averaging_time=0.1, settling_time=0.1, averaging_cycles=1, settling_cycles=1)
i.start_sweep(single=True)
frame = i.get_data(wait_complete=True)

```
