Inside a plugin i'm trying to load a wms layer, with python in QGIS. Everything works but the size doesn't match: is downloading the entire wms layer not the extent of the window i'm using in QGIS (cropped size). What i'm missing? Here is a sample of the request:
e = self.iface.mapCanvas().extent()
bbox = str(e.xMinimum())+","+str(e.yMinimum())+","+str(e.xMaximum())+","+str(e.yMaximum())
url = "http://myserver.com:8080/geoserver/ows"
serviceType = "wms"
urlWithParams = f"crs=EPSG:{epsg}&format=image/png&layers={layer_name}&styles&url={url}&bbox={bbox}"
QgsRasterLayer(urlWithParams, temp_layer_name , 'wms')