-
-
Notifications
You must be signed in to change notification settings - Fork 16
Troubleshooting
Listed are some problems you might occur during the journey of development. If you found anything else that could expand this list, feel free to open an issue, or leave me a message on Gitter!
See [MediaWiki] Advanced usages#private-wikis.
Basically this is because WCL receives HTML when it expects JSON response. If it's the first time you come across this exception, please check whether you have used the correct MW API endpoint URL. Note that if the URL provided causes HTTP 301 redirects, client library will usually fail to forward the request to the redirect target (POST request will be converted to GET request, and request body is lost). As for more information, see #38.
Many sites (including Wikipedia and other WMF projects) requires client to use TLS 1.2 protocol to set up connection. However, TLS 1.2 is not opt-in by the default secure transport configuration before .NET Framework 4.7. (#66) Thus you may need to change the configuration before the first connection is set up to your MediaWiki server.
using System.Net;
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
This is usually related to Cookies not being correctly set up. When you login to a specific MediaWiki site, the server will often drop several session cookies and expect client to send them back when sending further MediaWiki API requests. While the default constructor of WikiClient
has manually set HttpClientHandler.UseCookies
to true
to enable Cookies support, there could be other situations where the Cookies could get lost during communication, such as
- There is misconfiguration on the MediaWiki server or the reverse proxy, causing the Cookie domain or security policy mismatch.
Whenever after a successful login, WCL will refresh the WikiSite.AccountInfo
object. Any non-anonymous user should be inside a built-in "user"
group. When you see this assertion failure from Debugger or Warning message from logger, however, it means the freshly-fetched account information indicates the user is not inside the "user" group. This usually means you are no longer logged in when WCL send the second request to fetch account information.
If you have enabled account assertion with SiteOptions.AccountAssertion
, your next MediaWiki API request will be very likely to fail.
Such situation could be caused by
- You are logging out on the other
WikiSite
instance with the same API endpoint and the sameWikiClient
instance. - Session information loss. Please refer to section "Failed: Unable to continue login. Your session most likely timed out." for next steps.