Next time it happens, please connect a PC running e.g. YAT or Pronterface via USB, send M122, and post the report here. Then send M552 S-1 followed by M552 S1, wait for it to connect to your WiFi network, and see whether you can connect DWC again. These will help identify whether the issue is in the WiFi module or the main firmware.

I have a similar sounding problem, using a 1.01 duet wifi and most recent rc firmware, dwc2. When connection is lost, even rebooting the host PC and restarting browser (firefox) doesn't help. The print continues to finish perfectly. With YAT, M122 gives no response (on earlier occasions I have had a truncated response). M552 S-1 switches off the wifi, and M552 S1 switches it on, but still no connection. Board responds to M999 with reset, but M122 then gives a partial response and halts YAT with the error message 'an unhandled asynchronous non synchronised exception occurred while running YAT' the detailed info 0_1556045927327_20190423_yat_exception.txt
On restarting YAT, M122 then works fine.

@dc42 I am on main 2.03beta3(2019-03-25b6), WiFi 1.23, dwc 2.0.0rc6. I am only connecting via win10 pc/Firefox - deleted the duet app from phone and tablet at the moment, to eliminate concurrent connections.
Have the impression that this is a progressive thing - I initially get no response to M122, then M122 triggers a disconnect /reconnect, then connection is lost with multiple retrys from dwc.

I will increase the number of buffers in the 2.03 release, however I am not sure that increasing the number of buffers is the solution. The question is, why are all the buffers allocated and not getting released?

Do you access the Duet via the web interface from a single device (PC/tablet/smartphone), or from multiple devices? Many firmware versions ago there was a problem with buffer management if you turned a device off without disconnecting it from the Duet in DWC first; but that was fixed (it now times out and releases the buffers for that client after 10 seconds of inactivity form the client).

You can monitor the number of buffers when the machine is idle. When I run M122 from DWC with just a single web client and an attached PanelDue, it reports either 1 or 3 buffers allocated.

@dc42 I have only one computer and one connection to the web interface.
DWC too often sends requests. When many requests fail, repetitions are performed without a timer delay. IMHO at this moment buffers overflow.