In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to quickly grab and analyze the package in the development process of big data. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
In the past few days, the editor has encountered a strange event at work. The client uses Android native system and the server uses java. The requirement is that the client can upload photos in real time when taking photos. It is received and saved in the background and can be displayed on the platform. There is indeed a big hole in the seemingly simple function. There are two platforms, 192.168.31.87 platform is the test environment, 192.168.31.239 is the demonstration environment, test environment, demonstration environment, and Android client code are all the same, even mq,redis,nginx, database are the same. However, the Android upload test environment has been reported to java.net.SocketException, which is normal in the demo environment. Check the server code. I first used postman for testing.
Image.png
Since the same photo has been uploaded, failed is returned here, but the request is 200. It means that the call is normal. Then I wrote a test class on the microservice, and the result of the call with httpclient was normal.
Image.png
When uploading from an Android client, the normal and abnormal log are
Normal: response-- > Response {protocol=http/1.1, code=200, message=OK, url= http://192.168.31.239:8081/api/collDataUpload?para={%22fileName%22:%2220180822_185110_523.jpg%22,%22pno%22:%2220180821%22,%22dkey%22:%2215948c07-c718-4f32-a0af-4b7841fa95a0%22,%22stime%22:%221534935070523%22,%22etime%22:%221534935071000%22}} is abnormal: response-- > Response {protocol=http/1.1, code=400, message= Url= http://192.168.31.87:8081/api/collDataUpload?para={%22fileName%22:%2220180822_184559_902.jpg%22,%22pno%22:%228230%22,%22dkey%22:%22d351aa68-bace-438f-8d08-89ff598d4e04%22,%22stime%22:%221534934759902%22,%22etime%22:%221534934760000%22}}
Part of the Android client code
/ * * synchronize post-based image uploads * * @ param url * @ param file * @ return * / public Response uploadPic (String url, File file, String fileName) throws IOException {MultipartBody.Builder builder = new MultipartBody.Builder (); builder.setType (MultipartBody.FORM); Log.i ("huang", "files [0] .getName () =" + files [0] .getName () / / the first parameter should be consistent with the builder.addFormDataPart in Servlet ("file", fileName, RequestBody.create (MediaType.parse (guessMimeType (fileName)), file); MultipartBody multipartBody = builder.build (); Request request = new Request.Builder (). Url (url). Post (new ProgressRequestBody (multipartBody, listener)). Build (); okHttpClient.newCall (request) .enqueue (callback);}
Server side
Image.png
Then the client calls the server and does not even enter this interface. First, I check whether the configuration file has filtered the file size, and then I look at the filter. I can't figure it out. So I did a lot of operations. Although the problem was not solved in the end, there were a lot of new skills in get.
A very important skill: grabbing bags.
The rough steps are:
1. First execute the instructions on the linux server
two。 Call the interface, and then execute the instructions to download the linux file locally
3. Use Wireshark to view logs
Linux commands that need to be used
Netstat-tupln | grep 5088
Tcpdump-I any-p-s 0-w / tmp/cap.pcap
Sz / tmp/cap.pcap
Image.png
Image.png
Image.png
Then open it in the start menu.
Image.png
The software Wireshark can be downloaded by Baidu, a small partner.
Filter criteria can be entered in the address bar:
Ip.addr = = 192.168.31.182 and http
Image.png
Select the package you want to see, right-click the retro stream-> TCP stream or http stream
Image.png
Here's a general explanation:
Content-Type: upload file format multipart/form-data refers to the picture.
Boundary=XXXX, which is a form of addBoundary used in front-end upload.
Content-Length is the content size
Host: is the server host address
Connection is a link statu
Accept-Encoding is the received encoding format
User-Agent: it's uploaded by users. Here Android uses okhttp/3.6.0.
Content-Desposition is a description of the context
Content-Type: content type
Very happy, and get to a new skill, but my problem is still unsolved. The current solution is to write an Android end, use it as a button, and then use okhttp to upload the file to the platform.
In addition, when operating Android, I encountered the problem that adb.exe had stopped working and then could not start the virtual machine.
Image.png
Error screen:
Image.png
Generally speaking, the reason for this error is that the default end of adb is 5037, which is occupied by other programs. Editor, I have encountered being occupied by Cool my Music, Master Lu and 360mobile's exe program, and then I deleted all these programs!
First of all, we should check the port of 5037 on the computer and type netstat-aon | findstr "5037":
Image.png
We can see that the program with PID 4476 uses the shutdown port, and then we open the task manager.
Image.png
We can see that the process occupies port 5037 for the "360MobileLoader.exe * 32" process. In theory, we should just finish the process. But here's the problem!
Image.png
Image.png
I can't believe you won't let me delete it! PS: my own computer, do I still need your permission to delete it?
Image.png
Select "open file location" to find the corresponding exe program, I use here is 360 mandatory deletion, PS: ordinary deletion party also does not allow me to delete.
After I deleted it, the computer logged out again and adb.exe started normally.
Genymotion is back on. The little sister is back. Haha.
Image.png
A knowledge is attached: unbounded mouse. It is a mouse and keyboard to control N computers (which can be different operating systems).
Big data on the development process of how to quickly grasp the package and analysis to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.