MIDI inputs error occurred when switch back from another window to reaper

When my Window focus is not reaper I tend to get this error more often, for example when I use another window then switch back to reaper all my midi inputs cannot open. Does anyone experience similar problems and how can I solve it? It is quite frustrating especially when I am with a client and I have to restate the draw each time.
MIDI error
The following MIDI inputs could not be opened:
UM-2
Akai MPD24
OK
