No human being but commits sins and makes mistakes, either by violating a prohibition or neglecting an obligation, whether he knows them or not. So, for a Muslim, afflictions and trials in this world serve as purifiers so that he or she meets his or her Lord without or with the least burden of sins.
Trials and afflictions also could befall righteous people to raise their ranks with their Lord. The prophets and messengers of Allah were afflicted with a variety of the most tiresome and severe afflictions in their bodies, families, wealth, etc.
No one can know when his trial will come to an end. This actually should not be our concern. Our concern, however, should be to pass the test and to turn the affliction to a time of turning in penitent to Allah regarding it as a message to correct ourselves and put our feet on the right path.
It is only through strong faith and having hope in the mercy of Allah that a believer overcomes the difficulties he or she faces in this world. Despair may lead to disbelief or committing suicide or both of them.
As for complaining to people, if it is in a way that manifests discontent, impatience and protesting against the will and wisdom of Allah, then this is a great sin that a Muslim has to repent from regaining his trust and hope in Allah. But if one is just telling people about his or her case to seek their r counsel, advice, or du`a‘ showing his/her patience and content, this involves no harm insha‘ Allah.
Finally, we are advised to see those who are afflicted with more serious problems and diseases to know the grace of Allah on us. we should read the Qur’an and contemplate on the trials of the Messengers of Allah and how they faced them. we should read the biography of our Prophet (peace and blessings be upon him) and make du`a’ to Allah and pray humbly to Him to relieve our distress.