踩坑系列——后端代码在本地跑着,在本地对接口。后端接口在swagger和postman中都跑通了,但是在前端项目中出现get请求成功/post请求失败(一直说请求超时)的情况。本地用了mock数据
2021-09-08 08:55:31
复制上面的链接会转跳到首页???这是正常吗???应该怎么测呢??
松子说:转跳首页正常的。
后端代码在本地跑着,在本地对接口。后端接口在swagger和postman中都跑通了,但是在前端项目中出现get请求成功/post请求失败(一直说请求超时)的情况。排查问题。
-
另建一个项目demo,调用相同接口,走通了。那就排除后端代码问题,锁定为我正式项目中有配置or代码出问题了。
-
改了跟跑成功demo项目一样的端口,可以了。以为是端口原因,后面发现又不通了。把vue.config.js 中的mock的代码注释掉,发现跑通了。
-
确认问题在于mock的影响。参考对应文章,尝试看看跟着操作是否能走通。跟着修改 mock/mock-server.js 的相关代码后,问题解决。走通了。
报错如下,参考对应文章,尝试看看跟着操作是否能走通。
.HTTPMESSAGENOTREADABLEEXCEPTION: I/O ERROR WHILE READING INPUT MESSAGE; NESTED EXCE:
参考文章解决,搜索找到这篇文章:“POSTMAN能请求到后端接口,.HTTPMESSAGENOTREADABLEEXCEPTION: I/O ERROR WHILE READING INPUT MESSAGE; NESTED EXCE”
找到 mock/mock-server.js 文件,进行相关修改即可。这样就可以在部分接口不全的情况下,用到mock的数据,还能兼顾跟后端对接口。
for (const mock of mocksForServer) {
app[mock.type](
mock.url,
bodyParser.json(),
bodyParser.urlencoded({
extended: true,
}),
mock.response,
mockLastIndex = app._router.stack.length
module.exports = (app) => {
在平时的工作,js报错是比较常见的一个情景,尤其是有一些错误可能我们在本地测试的时候测试不出来,当发布到线上之后才可以发现,如果抢救及时,那还好,假如很晚才发
现,那就可能造成很大的损失了。如果我们前端可以监控到这种报错,并及时上报的话,那我们的问题就比较好解决了。所以我们今天来聊聊前端代码的异常监控
什么是前端代码异常
一般语法错误以及运行时错误,浏览器都会在console里边体现出错误信息,以及出错的文件,行号,堆栈信息。
我们先来说手前端代码异常是什么意思。前端代
Preface Part I. The Basics 1. What Is C++? A Brief History of C++ C++ Organization How to Learn C++ 2. The Basics of Program Writing Programs from Conception to Execution Creating a Real Program Getting Help in Unix Getting Help in an IDE Programming Exercises 3. Style Comments C++ Code Naming Style Coding Religion Indentation and Code Format Clarity Simplicity Consistency and Organization Further Reading Summary 4. Basic Declarations and Expressions Basic Program Structure Simple Expressions The std::cout Output Object Variables and Storage Variable Declarations Assignment Statements Floating-Point Numbers Floating-Point Divide Versus Integer Divide Characters Wide Characters Boolean Type Programming Exercises Answers to Chapter Questions 5. Arrays, Qualifiers, and Reading Numbers Arrays Strings Reading Data Initializing Variables Multidimensional Arrays C-Style Strings Types of Integers Types of Floats Constant and Reference Declarations Qualifiers Hexadecimal and Octal Constants Operators for Performing Shortcuts Side Effects Programming Exercises Answers to Chapter Questions 6. Decision and Control Statements if Statement else Statement How Not to Use std::strcmp Looping Statements while Statement break Statement continue Statement The Assignment Anywhere Side Effect Programming Exercises Answers to Chapter Questions 7. The Programming Process Setting Up Your Work Area The Specification Code Design The Prototype The Makefile Testing Debugging Maintenance Revisions Electronic Archaeology Mark Up the Program Use the Debugger Use the Text Editor as a Browser Add Comments Programming Exercises Part II. Simple Programming 8. More Control Statements for Statement switch Statement switch, break, and continue Programming Exercises Answers to Chapter Questions 9. Variable Scope and Functions Scope and Storage Class Namespaces Functions Summary of Parameter Types Recursion Structured Programming Basics Real-World Programming Programming Exercises Answers to Chapter Questions 10. The C++ Preprocessor define Statement Conditional Compilation include Files Parameterized Macros Advanced Features Summary Programming Exercises Answers to Chapter Questions 11. Bit Operations Bit Operators The AND Operator (&) Bitwise OR (|) The Bitwise Exclusive OR (^) The Ones Complement Operator (NOT) (~) The Left and Right Shift Operators (>) Setting, Clearing, and Testing Bits Bitmapped Graphics Programming Exercises Answers to Chapter Questions Part III. Advanced Types and Classes 12. Advanced Types Structures Unions typedef enum Type Bit Members or Packed Structures Arrays of Structures Programming Exercises Answers to Chapter Questions 13. Simple Classes Stacks Improved Stack Using a Class Introduction to Constructors and Destructors Automatically Generated Member Functions Shortcuts Style Structures Versus Classes Programming Exercises 14. More on Classes Friends Constant Functions Constant Members Static Member Variables Static Member Functions The Meaning of static Programming Exercises 15. Simple Pointers const Pointers Pointers and Printing Pointers and Arrays The reinterpret_cast Pointers and Structures Command-Line Arguments Programming Exercises Answers to Chapter Questions Part IV. Advanced Programming Concepts 16. File Input/Output C++ File I/O Conversion Routines Binary and ASCII Files The End-of-Line Puzzle Binary I/O Buffering Problems Unbuffered I/O Designing File Formats C-Style I/O Routines C-Style Conversion Routines C-Style Binary I/O C- Versus C++- Style I/O Programming Exercises Answers to Chapter Questions 17. Debugging and Optimization Code Reviews Serial Debugging Going Through the Output Interactive Debuggers Debugging a Binary Search Interactive Debugging Tips and Tricks Runtime Errors Optimization How to Optimize Case Study: Inline Functions Versus Normal Functions Case Study: Optimizing a Color-Rendering Algorithm Programming Exercises Answers to Chapter Questions 18. Operator Overloading Creating a Simple Fixed-Point Class Operator Functions Operator Member Functions Warts Full Definition of the Fixed-Point Class Programming Exercises Answers to Chapter Questions 19. Floating Point Floating-Point Format Floating Addition/Subtraction Multiplication and Division Overflow and Underflow Roundoff Error Accuracy Minimizing Roundoff Error Determining Accuracy Precision and Speed Power Series Programming Exercises 20. Advanced Pointers Pointers, Structures, and Classes delete Operator Linked Lists Ordered Linked Lists Doubly Linked Lists Trees Printing a Tree The Rest of the Program Data Structures for a Chess Program Programming Exercises Answers to Chapter Questions 21. Advanced Classes Derived Classes Virtual Functions Virtual Classes Function Hiding in Derived Classes Constructors and Destructors in Derived Classes The dynamic_cast Operator Summary Programming Exercises Answers to Chapter Questions Part V. Other Language Features 22. Exceptions Adding Exceptions to the Stack Class Exceptions Versus assert Programming Exercises 23. Modular Programming Modules Public and Private The extern Storage Class Headers The Body of the Module A Program to Use Infinite Arrays The Makefile for Multiple Files Using the Infinite Array Dividing a Task into Modules Module Design Guidelines Programming Exercises 24. Templates What Is a Template? Templates: The Hard Way Templates: The C++ Way Function Specialization Class Templates Class Specialization Implementation Details Advanced Features Summary Programming Exercises 25. Standard Template Library STL Basics Class List-A Set of Students Creating a Waiting List with the STL List Storing Grades in a STL Map Putting It All Together Practical Considerations When Using the STL Getting More Information Exercises 26. Program Design Design Goals Design Factors Design Principles Coding Objects Real-World Design echniques Conclusion 27. Putting It All Together Requirements Code Design Coding Functional Description Testing Revisions A Final Warning Program Files Programming Exercises 28. From C to C++ K&R-Style Functions struct malloc and free Turning Structures into Classes setjmp and longjmp Mixing C and C++ Code Summary Programming Exercise 29. C++’s Dustier Corners do/while goto The ? : Construct The Comma Operator Overloading the ( ) Operator Pointers to Members The asm Statement The mutable Qualifier Run Time Type Identification Trigraphs Answers to Chapter Questions 30. Programming Adages General Design Declarations switch Statement Preprocessor Style Compiling The Ten Commandments for C++ Programmers Final Note Answers to Chapter Questions Part VI. Appendixes A. ASCII Table B. Ranges C. Operator Precedence Rules D. Computing Sine Using a Power Series E. Resources Index
Ace 是一个用 JavaScript 编写的独立代码编辑器。我们的目标是创建一个基于浏览器的编辑器,以匹配和扩展现有本地编辑器(如 TextMate、Vim 或 Eclipse)的功能、可用性和性能。它可以很容易地嵌入到任何网页或 JavaScript 应用程序中。
超过 120 种语言的语法高亮显示(可以导入TextMate/Sublime/ .tmlanguage文件)
超过 20 个主题(可以导入TextMate/Sublime/ .tmtheme文件)
自动缩进和升级
一个可选的命令行
处理巨大的文档(最后检查,4,000,000 行是上限)
完全可定制的键绑定,包括 vim 和 Emacs 模式
使用正则表达式搜索和替换
突出显示匹配的括号
在软选项卡和真实选项卡之间切换
显示隐藏字符
使用鼠标拖放文本
代码折叠
多个光标和选择
实时语法检查器(当前为 JavaScript/CoffeeScript/CSS/XQuery)
剪切、复制和粘贴功能
最近在写前后端项目过程中,针对容易出现的timeout问题,查阅相关资料,自己整理分享一些处理方式如下:
针对前端请求,后端因为断点或者电脑反应延迟、网络延迟等现象,明明后端接口能正常返回数据还报连接超时问题,可在前端vue的utils里面的request.js里面设置如下:
因为最近写的springcloud微服务项目,在fegin调用过程中,出现的超时问题,可在application.properties文件增加两行配置如下图:
代码为:
feign.client.config.default.
问题场景数据计算量过大,接口响应时间过长时,网关会报超时,页面就挂了,没有更好的解决办法,暂时采用了一个临时方案,步骤如下:1.将原本的一个接口拆分为3个,三个接口异步操作。三个接口作用及描述如下:接口1:获取本地异步操作的唯一标识-唯一且加密后的code值请求体:此次查询操作的查询条件返回体:唯一的加密后的唯一code接口2:轮询此次查询的结果是否已计算并准备好请求体:接口1返回的code返回体...
前后端分离项目,前端和后端人员都是根据 API 文档进行开发项目的,不应该直接相互依赖, 前端人员不应该等
待后端开发好接口后再进行测试,既然不依赖后端接口,那前端人员应该如何测试呢?
可以通过模拟数据生成器,通过一定规则 (API文档)生成模拟数据接口, 提供给前端人员进行测试。
什么是 Mock.js
官网:mock官网
文档:mock.js文档
Mock.js 是用于生成随机数据,拦截 Ajax 请求。
通过拦截 Ajax 请求,根据数据模板生成
经过一波操作找到了这个问题的解决方法:
原因是一个解决方案里包括了多个项目,我们可能在其中一个项目中调用了这个接口,这个项目的app.config文件里有对应的接口信息。
还需要将这个接口的配置信息复制到主程序的app....
var fileInput = document.querySelector('#file-input');
fileInput.onchange = function(){
console.log('文件名:',this.value)
var formData = n
最近公司项目对接第三方,调用接口需要挂V*N,本地开启后,使用postman、APIpost等请求工具都能正常请求到数据,但Java代码一直报conectfailed,猜测大概率是没有通过虚拟IP发起请求。
最终解决:idea启动时增加启动项-Djava.net.preferIPv4Stack=true
SpringMVC控制层接收前端多个参数,报错I/O error while reading input message; nested exception is java.io.IOException: Stream closed
【Controller】
@PostMapping("/list")
public Result<List<ReviseInfo>> list(@RequestBody ReviseInfo reviseInfo, @RequestBody R
2016-05-2508:58:34
昨天线上小白系统因为调用外部http接口,超时不释放,导致页面反应很慢,时间一长,报502错误。
上网查了下,502错误是因为服务对于客户的请求没有得到及时的反应,查询日志,发现很多调http接口异常,页面反应也很慢。
瞬间想到缩短http客户端调用http接口的超时时间,搜到这个博客http://blog.csdn.net/xinying0424/a...